【发布时间】:2016-08-24 11:00:11
【问题描述】:
需要编写一个文件(pdf)并将其存储在设备内存中。我正在使用 react-native-fs 库。
我想让用户也能够使用 iBooks 阅读此文件。
这些是 react-native-fs 的常量
- MainBundlePath (String) 主包的绝对路径 目录
- CachesDirectoryPath (String) 缓存的绝对路径 目录
DocumentDirectoryPath (String) 文档的绝对路径 目录
TemporaryDirectoryPath (String) 临时目录的绝对路径 目录(仅限 iOS)
这是我的下载代码
RNFS.downloadFile({
fromUrl: fileLink,
toFile: RNFS.MainBundlePath + '/' + fileName
}).promise.then((dwResult) => {
console.log(dwResult.jobId + 'jobid');
return true
}).catch((err) => {
alert(err);
return false
})
}
我必须分配什么 toFile 以便可以使用 iBooks 看到写入的文件。 注意:我可以使用 DocumentDirectoryPath 编写文件应用程序的路径。
【问题讨论】:
标签: ios react-native react-native-fs