【发布时间】:2017-05-12 03:43:38
【问题描述】:
我使用react-native-camera 来点击图片。我在该州存储的相机数据中得到一个文件路径,如:“file:///storage/emulated/0/Pictures/IMG_20161228_021132.jpg”。我可以将其用作使用图像组件“Image source={{uri:this.props.note.imagePath.path}}”显示图像的源,并且它可以正常显示。
现在我想添加删除图像功能。有人可以建议如何使用上述路径在手机中访问此图像并将其从手机中删除。
我检查了react-native-filesystem,但是当我使用在此路径中传递的 checkIfFileExists 函数时,我发现该文件不存在。不知道出了什么问题。
async checkIfFileExists(path) {
const fileExists = await FileSystem.fileExists(path);
//const directoryExists = await FileSystem.directoryExists('my-directory/my-file.txt');
console.log(`file exists: ${fileExists}`);
//console.log(`directory exists: ${directoryExists}`);
}
deleteNoteImage (note) {
console.log(note.imagePath.path);
//check if file exists
this.checkIfFileExists(note.imagePath.path);
//console.log();
note.imagePath = null;
this.updateNote(note);
}
【问题讨论】: