react-native-file-access icon indicating copy to clipboard operation
react-native-file-access copied to clipboard

Write Blob, instead of just string

Open ShivamJoker opened this issue 1 year ago • 2 comments

Feature I am creating an XLSX file and I would like to save it in the file system.

But right now the only way is to convert it to string, which might not work since it's a compressed files.

Motivation It can be used to save images and other media files too.

ShivamJoker avatar Oct 31 '23 07:10 ShivamJoker

I tried the base64 method but it says bad base64

This is what my string looks like:

data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,UEsDBBQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

ShivamJoker avatar Oct 31 '23 10:10 ShivamJoker

Good idea. Not sure when I will have time to implement though, as I am quite busy currently (pull requests always welcome).

Until then, you can use a workaround to get it working in your app. Trouble is that string is a data URL, not pure base64 data. Here are a variety of ways to convert the blob so it will work with base64 methods of this library.

alpha0010 avatar Oct 31 '23 16:10 alpha0010