upload pdf file from storage to firebase in react-native

Viewed 908

I have been trying to upload PDF file from phone storage to Firebase. Its working fine when I use react-native-document-picker to select a pdf file, which returns the path of the file something like content://com.android.externalstorage.documents/document/primary%3Adocs%2F' +'<filename>'.pdf' which is then passed to fetch

  const response = await fetch(path);
  blob = await response.blob();

and then the blob is uploaded to Firebase.

But the problem is that I don't want to pick a document every time. if I don't use react-native-document-picker and just curate the exact path return by the module. it gives network error when passed to fetch, so unable to create a blob. I also tried react-native-fs but couldn't figure out how to create a blob of PDF residing in emulated storage.

0 Answers
Related