Open ChristianWeyer opened 8 years ago
We should use the File API in Cordova - something like this: var onCordovaDeviceReady = () => { const camera = window.navigator.camera;
var options = {
quality: 20,
targetWidth: 400,
destinationType: camera.DestinationType.FILE_URI,
sourceType: camera.PictureSourceType.CAMERA,
encodingType: camera.EncodingType.PNG,
saveToPhotoAlbum: false,
correctOrientation: true
};
camera.getPicture(imageUri => {
window.resolveLocalFileSystemURL(imageUri, function (fileEntry) {
var imageFileUrl = fileEntry.nativeURL;
observer.next(imageFileUrl);
removeDomListener();
observer.complete();
});
}, error => {
observer.error(error);
removeDomListener();
observer.complete();
}, options);
};
Then we should post the data as multipart mime. There is a sample how to implement this in my old sample app.
Server/Web API: https://github.com/ChristianWeyer/myProducts-End-to-End/blob/master/src/myProducts.Services/Controllers/ArticlesController.cs#L114
By using the standard e.g. iPhone camera we get very large photos with the current code. It can tkae ages to upload and ages to download all the photos.
We need to optimize this e.g. on Cordova.
We could create thumbnails on the server as well.