mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 17:03:26 +00:00
Compare commits
1 Commits
21e34f9212
...
daba32627b
Author | SHA1 | Date | |
---|---|---|---|
|
daba32627b |
@@ -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", {
|
||||||
|
Reference in New Issue
Block a user