alpha0010 / react-native-file-access

Filesystem access for React Native
MIT License
298 stars 18 forks source link

Write Blob, instead of just string #78

Open ShivamJoker opened 8 months ago

ShivamJoker commented 8 months ago

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 commented 8 months ago

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
alpha0010 commented 8 months ago

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.