joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.81k stars 772 forks source link

Image file is corrupted after writing it to the cache directory. #604

Open dev7050 opened 4 years ago

dev7050 commented 4 years ago

I am unable to open image after I store it to cache directory. In my case, I am creating file in which I am storing the base 64 image data. But that file is not opened and show corrupted message.

Here is my code snippet:

var base64Img = noexifbase64.split("base64,")[1]; var cachepath = RNFetchBlob.fs.dirs.CacheDir + /${TimeStamp}.jpg RNFetchBlob.fs.createFile(cachepath, RNFetchBlob.base64.encode(base64Img), 'base64')

VishalMahesh commented 4 years ago

The issue persist on your file creation method. You need to change it to :

RNFetchBlob.fs.createFile(cachepath, base64Img, 'base64')