Open niraj-khatiwada opened 1 year ago
@niraj-khatiwada Please did you find a way around this ?? having same issues on IOs
@niraj-khatiwada did you find a way to solve it?
const { dirs } = RNFetchBlob.fs; const PictureDir = Platform.OS === 'ios' ? dirs.DocumentDir : dirs.PictureDir ;
@A-Vijay have tried this didnt work either, i add to use the RNFetchBlob.ios.previewDocument.(response?.path()) so this shows a dialogue prompting the user where to save the file. which i dont like the flow.
const configOptions = Platform.select({ ios: { fileCache: true, path: fPath, appendExt: ext } });
let imagePath = null;
RNFetchBlob.config(configOptions)
.fetch('GET', image_URL)
.then( (res) => {
imagePath = res.path();
return res.readFile('base64');
}).then(base64Data => {
this.setState({ showDownloadingLoader: false }) ;
if (Platform.OS == 'ios'){
RNFetchBlob.fs.writeFile(imagePath, base64Data, 'base64') .then( (res) => {
console.log('IMAGE saved ', res);
});
}
})
.catch((e) => {
console.log('The file ERROR', e.message);
});
@tdammy92 can you check this once. One the image is saved you can check that in your files.
const configOptions = Platform.select({ ios: { fileCache: true, path: fPath, appendExt: ext } });
let imagePath = null; RNFetchBlob.config(configOptions) .fetch('GET', image_URL) .then( (res) => { imagePath = res.path(); return res.readFile('base64'); }).then(base64Data => { this.setState({ showDownloadingLoader: false }) ; if (Platform.OS == 'ios'){ RNFetchBlob.fs.writeFile(imagePath, base64Data, 'base64') .then( (res) => { console.log('IMAGE saved ', res); }); } }) .catch((e) => { console.log('The file ERROR', e.message); });
@tdammy92 can you check this once. One the image is saved you can check that in your files.
Ok thanks will implement and give a feedback.
const configOptions = Platform.select({ ios: { fileCache: true, path: fPath, appendExt: ext } });
let imagePath = null; RNFetchBlob.config(configOptions) .fetch('GET', image_URL) .then( (res) => { imagePath = res.path(); return res.readFile('base64'); }).then(base64Data => { this.setState({ showDownloadingLoader: false }) ; if (Platform.OS == 'ios'){ RNFetchBlob.fs.writeFile(imagePath, base64Data, 'base64') .then( (res) => { console.log('IMAGE saved ', res); }); } }) .catch((e) => { console.log('The file ERROR', e.message); });
@tdammy92 can you check this once. One the image is saved you can check that in your files.
return res.readFile('base64');
return undefined
Works on IOS but I can't seem to figure out how to save in IOS.
Code:
Here svg.current is the base64 url with no
data:image/png;base64,
The
writeFile
does not show any error, but the images are not saved.Thanks!