How to get file from a component or download a file in stream base64

So the problem I’m having is that I want to download a file (pictures, PDF, etc) for the sharing, the problem is that I get a stream in base64, I can show them like this:

<Image
source={{
uri: data:image/${fileSelected.extension.toLowerCase()};base64,${ fileSelected.stream },
}}

or for PDF

<PDFReader
style={{ width: “100%”, height: “100%” }}
source={{
base64: “data:application/pdf;base64,” + fileSelected.stream,
}}
/>

but when I want to download those, I don’t know how to do it

if i want to get to the pdf like this

if (!(await Sharing.isAvailableAsync())) {
alert(Uh oh, sharing isn't available on your platform);
return;
}
let filetoSave = “data:application/pdf;base64,” + fileSelected.stream
await Sharing.shareAsync(filetoSave)

I get this error
Unhandled promise rejection: Error: You don’t have access to provided file.

1 Like