revert 删除saveImage方法的catch,排查生产环境ios不能保存图片的原因
This commit is contained in:
yezian 2024-03-23 15:29:03 +08:00
parent dbcd874261
commit 965a727131
1 changed files with 13 additions and 8 deletions

View File

@ -7,14 +7,19 @@ export default async function saveImage(uri) {
if (permission.granted) {
const timestamp = new Date().getTime();
const fileUri = FileSystem.cacheDirectory + `${timestamp}.png`;
const res = await FileSystem.downloadAsync(uri, fileUri);
await MediaLibrary.saveToLibraryAsync(res.uri);
Toast.show({
type: "success",
text1: "已保存到相册",
topOffset: 60,
});
return true;
try {
const res = await FileSystem.downloadAsync(uri, fileUri);
await MediaLibrary.saveToLibraryAsync(res.uri);
Toast.show({
type: "success",
text1: "已保存到相册",
topOffset: 60,
});
return true;
} catch (err) {
console.error("FS Err: ", err);
return false;
}
} else {
Toast.show({
type: "error",