mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 14:53:24 +00:00
Compare commits
2 Commits
8d1ec8f1dc
...
7b17b2c103
Author | SHA1 | Date | |
---|---|---|---|
|
7b17b2c103 | ||
|
5def4e8461 |
@@ -1,6 +1,7 @@
|
|||||||
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";
|
||||||
@@ -132,14 +133,16 @@ 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: localUri,
|
localPath: Platform.select({
|
||||||
|
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