我試圖使用react-native-fs和react-native-document picker將從文檔選擇器選擇的文件移動到文檔目錄。將文件從tmp移動到使用react-native-f的文檔
不過,我得到以下錯誤:
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);
});
}