【发布时间】:2020-05-27 01:41:24
【问题描述】:
我正在使用以下代码从 API 下载选定的 PDF 文档:
DownloadDocument = (docUri) => {
FileSystem.makeDirectoryAsync(FileSystem.documentDirectory + 'app_docs/', { intermediates: true });
FileSystem.downloadAsync(
' https://example.com/library/documents/' + docUri,
FileSystem.documentDirectory + 'app_docs/' + docUri
)
.then(({ uri }) => {
console.log('Finished downloading to ', uri);
})
.catch(error => {
console.error(error);
});
}
有没有办法循环所有已下载到 app_docs 文件夹中的文档?
我一直在尝试使用FileSystem.readDirectoryAsync(FileSystem.documentDirectory + 'app_docs'),但没有太多乐趣。
【问题讨论】:
标签: react-native expo