This code - ionic 3 capacitor - from josh morony takes a photo from the tmp directory and writes to the Document directory in this section using the FileSystem API the retrieves and manipulates the path
Filesystem.writeFile({ data: result.data, path: fileName, directory: FilesystemDirectory.Data })getFromPhotos() { let options = { resultType: CameraResultType.Uri }; Camera.getPhoto(options).then((photo) => { Filesystem.readFile({ path: photo.path }).then((result) => { // let date = new Date(), // time = date.getTime(), time = 'bilder', fileName = time +'.jpeg'; Filesystem.writeFile({ data: result.data, path: fileName, directory: FilesystemDirectory.Data }).then((result) => { Filesystem.getUri({ directory: FilesystemDirectory.Data, path: fileName }).then((result) => { console.log(result); let path = result.uri.replace('file://', '_capacitor_'); this.image = this.sanitizer.bypassSecurityTrustResourceUrl(path); }, (err) => { console.log(err); }); }, (err) => { console.log(err); }); }, (err) => { console.log(err); });}, (err) => { console.log(err);});
}
In ionic 3 you have to use the cordova File plugin - please google. It is pretty straight forward to understand: you define the original directory where the file is, the original name of the file, the target directory, and a new name for the file inside that function. The principle is the same.