I took a picture using a sample of the new CameraView.
(https://github.com/fusetools/fuse-samples/tree/master/Samples/Camera)
console.log ("Photo saved to:" + filePath);
In this part, filePath is [/storage/emulated/0/Android/data/com.apps.testphoto/cache/images/IMG_00097203-27c6-4d3a-9d8e-3e65095c4867.jpeg]
So, I tried to upload this file to the server. (use fetch)
photo.save()
.then(function(filePath) {
console.log("Photo saved to: " + filePath);
// fileFullPath.value = filePath;
upload(filePath);
photo.release();
})
.catch(function(error) {
console.log("Failed to save photo: " + error);
photo.release();
});
function upload(filePath) {
FileSystem.getFileInfo(filePath)
.then(function(fileInfo) {
console.log("file was modified on ",JSON.stringify(fileInfo));
FileSystem.readBufferFromFile(filePath)
.then(function(contents) {
console.log(contents);
}, function(error) {
console.log(error);
});
})
.catch(function(error) {
"failed stat " + error
});
}
I tried this.
console.log ("file was modified on", JSON.stringify (fileInfo));
In this part,
output :
{"length":28924,"exists":true,"fullName":"/storage/emulated/0/Android/data/com.apps.testphoto/cache/images/IMG_00097203-27c6-4d3a-9d8e-3e65095c4867.jpeg","lastWriteTime":"2017-11-19T17:52:56.000Z","lastAccessTime":"2017-11-19T17:52:56.000Z"}
but,
When reading with [FileSystem.readBufferFromFile], no value could be read.
When using Storage.read, it says that the file does not exist.
I was in confusion. Help me plaese!
How can I upload this captured picture to the server?