我正在使用Expo.Filesystem.downloadAsync下载大号。图片和视频之类的文件。但有时有时会无限期地卡住。我打算在循环内下载文件。代码是:
let image_downloading = section.map(async (item, i) => {
item.image !== null ?
await FileSystem.downloadAsync(item.image,
directory + item.image.split("/").reverse()[0]
)
.then(({ uri }) => {
item['image'] = uri;
console.log('Finished downloading section to ', uri);
})
.catch(({error}) => {
console.log('errorrrrrrrrrrrrr',error)
})
: null
});
await Promise.all(image_downloading);
Run Code Online (Sandbox Code Playgroud)
我也尝试过使用FileSystem.createDownloadResumable。使用createDownloadResumable时,下载速度非常慢