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