我正在构建一个 react-native 应用程序。该应用程序包含各种课程。这些课程可以离线使用。使用 react-native-fs,如何同时下载 2 个或更多课程?
import { Platform } from "react-native";
import RNFetchBlob from 'rn-fetch-blob'
import { _unzipAll } from "@lib/unZip";
import { DocumentDirectoryPath, LibraryDirectoryPath } from "react-native-fs";
import {
DOWNLOADED_FILE_PATH,
DOWNLOADED_FILE_DIRECTORY
} from "@config/constants";
let parentPath =
Platform.OS === "ios" ? LibraryDirectoryPath : DocumentDirectoryPath;
export function downloadAllFileZip(targetPath, props, id) {
console.log("props id val",id);
console.log("download alll lib", props.courseofflineurl);
try {
RNFetchBlob.config({
path: targetPath
})
.fetch(
"GET",
props.courseofflineurl
)
.progress((received, total) => {
percentage = Math.ceil((received / total) * 100);
console.log("percentage" + percentage)
// getDetails(percentage);
})
.then(res => {
console.log("Downloadedd", res)
_unzipAll(targetPath, parentPath + DOWNLOADED_FILE_DIRECTORY + id, props,id);
})
.catch(error => { });
} catch (error) { }
}