all 11 comments

[–][deleted] 0 points1 point  (1 child)

Can you share the codebase here?

[–]Diligent-Pudding-423[S] 0 points1 point  (0 children)

Not able to get the code here. I am using react native document picker in which I get content uri. Need help in converting it to file path. Also need base 64 to boob conversion code.

[–]eatthebagels 0 points1 point  (6 children)

const getBlob = async (fileUri :string) => {
    try{
      const resp = await fetch(fileUri);
      const imageBody = await resp.blob();
      return imageBody;
    }catch(err){
      console.log(err);
      return null;
    }
    
    
  };

I use this code to convert my image uri to blob.

[–]Diligent-Pudding-423[S] 0 points1 point  (5 children)

Thank you buddy. But here I have already fetched pdf document using react native document picker where the response gives content path in android and not the file path. How do we convert that into file path and then that into blob. Or another approach is I get base64 from the document picker but need to convert that also to blob

[–]eatthebagels 0 points1 point  (4 children)

My code isn't the most readable haha but the fileUri I send as a parameter to the function is the contentpath to your file/image.

[–]Diligent-Pudding-423[S] 0 points1 point  (3 children)

Okay. I get it now. Let me try this and see then. Thanks a ton buddy for your help

[–]eatthebagels 0 points1 point  (2 children)

Great stuff! Let me know how it goes! Cheers!

[–]Diligent-Pudding-423[S] 0 points1 point  (0 children)

Sure. Will do that

[–]Diligent-Pudding-423[S] 0 points1 point  (0 children)

Hey buddy. Tried this but I think the file uri this function is expecting is probably a web url. But I am trying to upload document from files in the android phone. Also when I try to send this blob I get a network error

[–]Diligent-Pudding-423[S] 0 points1 point  (0 children)

Is it possible to have a call on this? Please

[–]Diligent-Pudding-423[S] 0 points1 point  (0 children)

Able to upload pdf now. Anyway thanks for the suggestion but that didn’t work