forked from wkh237/react-native-fetch-blob
-
Notifications
You must be signed in to change notification settings - Fork 791
Open
Description
import RNFetchBlob from 'rn-fetch-blob';
import {Platform} from 'react-native';
import {generateUuid} from './helpers';
export const saveImageBase64 = async (
base64String: string,
successCallback: () => void,
) => {
const fileName = `${generateUuid()}.png`;
const dirs = RNFetchBlob.fs.dirs;
const Base64Code = base64String.split('data:image/png;base64,');
const filePath = `${
Platform.OS === 'android' ? dirs.DownloadDir : dirs.DocumentDir
}/${fileName}`;
RNFetchBlob.fs
.writeFile(filePath, Base64Code[1], 'base64')
.then(() => {
if (Platform.OS === 'ios') {
RNFetchBlob.ios.openDocument(filePath);
} else {
successCallback();
}
})
};
What I have here is saveImageBase64
function , that perfectly works on Android
, it saves my image , and I'm happy , but on ios , function doesn't send any error , seems like all is working well , but when I try to open this image by RNFetchBlob.ios.openDocument(filePath);
, it just show me :
what does it mean ? and could someone show me how can I save my file , and open it , or just save on ios
, because I don't see that anything saved to my Document
dir
Metadata
Metadata
Assignees
Labels
No labels