Skip to content

Option to pass body to fetchBlob #170

@ezze

Description

@ezze

Is your feature request related to a problem? Please describe.

I am trying to download a big file using our API

const options: BlobFetchInput = {
  method: 'POST',
  filename: 'offline.db',
  headers: {
    Authorization: `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  android: {
    target: 'data'
  },
  mimeType: 'application/octet-stream',
  url: `${apiUrl}api/v1/client-db/clone`
};

const response = await BlobCourier.fetchBlob(options);

JSON body with request parameters must be part of the request but unfortunatelly I didn't find such option for fetchBlob.

Describe the solution you'd like

I want my request to look like this:

const options: BlobFetchInput = {
  method: 'POST',
  filename: 'offline.db',
  headers: {
    Authorization: `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ facilityIds })
  android: {
    target: 'data'
  },
  mimeType: 'application/octet-stream',
  url: `${apiUrl}api/v1/client-db/clone`
};

Describe alternatives you've considered

At the moment I use FileSystem.fetch from react-native-file-access but unfortunately it doesn't provide a way to cancel a long request:

const options = {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  path: getDatabasePath(dbName),
  body: JSON.stringify({ facilityIds })
};
const url = `${apiUrl}api/v1/client-db/clone`;
const response = await FileSystem.fetch(url, options, onProgress);

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions