Compare commits

..

1 Commits

Author SHA1 Message Date
Adrian Castro
daba32627b Merge 8d1ec8f1dc into a3f184979e 2024-04-13 19:56:26 +00:00

View File

@@ -1,7 +1,6 @@
import type { DownloadProgressData } from "expo-file-system"; import type { DownloadProgressData } from "expo-file-system";
import type { Asset } from "expo-media-library"; import type { Asset } from "expo-media-library";
import { useCallback, useState } from "react"; import { useCallback, useState } from "react";
import { Platform } from "react-native";
import * as FileSystem from "expo-file-system"; import * as FileSystem from "expo-file-system";
import * as MediaLibrary from "expo-media-library"; import * as MediaLibrary from "expo-media-library";
import * as Network from "expo-network"; import * as Network from "expo-network";
@@ -133,16 +132,14 @@ export const useDownloadManager = () => {
); );
try { try {
updateDownloadItem(download.id, { status: "importing" }); updateDownloadItem(download.id, { status: "importing" });
const asset = await MediaLibrary.createAssetAsync(fileUri); const asset = await MediaLibrary.createAssetAsync(fileUri);
const { localUri } = await MediaLibrary.getAssetInfoAsync(asset); const { localUri } = await MediaLibrary.getAssetInfoAsync(asset);
await FileSystem.deleteAsync(fileUri); await FileSystem.deleteAsync(fileUri);
updateDownloadItem(download.id, { updateDownloadItem(download.id, {
status: "finished", status: "finished",
localPath: Platform.select({ localPath: localUri,
ios: localUri,
android: asset.uri,
}),
}); });
console.log("File saved to media library and original deleted"); console.log("File saved to media library and original deleted");
showToast("Download finished", { showToast("Download finished", {