【发布时间】:2017-06-05 21:19:32
【问题描述】:
我正在尝试使用 react-native-fs 和 react-native-document picker 将从文档选择器中选择的文件移动到文档目录。
但是,我收到以下错误:
Error: “file name.mp3” couldn’t be moved to “Documents” because either the former doesn't exist, or the folder containing the latter doesn't exist.
我做错了什么?
仅供参考,我使用的是 iOS。
openDocumentPicker() {
DocumentPicker.show({
filetype: ['public.audio'],
},(error,url) => {
console.log(url);
this.saveAudio(url);
});
}
saveAudio(url) {
var destPath = RNFS.DocumentDirectoryPath + '/' + 'name';
RNFS.moveFile(url, destPath)
.then((success) => {
console.log('file moved!');
})
.catch((err) => {
console.log("Error: " + err.message);
});
}
【问题讨论】:
标签: react-native react-native-ios react-native-fs