Reputation: 417
I am trying to upload a photo taken from the camera, but running into issues with tying the resulting photo with file transfer.
I have installed the following plugins: cordova-plugin-camera, cordova-plugin-file, cordova-plugin-file-transfer
I am able to take a picture and display it in an ionic page. What I don't understand is how to tie that photo with the file-transfer process. A real end-to-end example of a live photo taken and uploaded.
So far I have come across many examples of taking a photo -- or -- uploading a previously existing file. But not both in one go.
On a related note that I have this working using the browser camera functions and can successfully upload the file object into my web service (written in C#). It works in iOS but recently the Android device no longer offers a live photo to be taken for some reason (would love to know why).
Are there any end-to-end examples of taking a photo, uploading it -- and -- into a C# written web-service?
Upvotes: 0
Views: 2306
Reputation: 1714
Have you tried doing it like this:
var options = {
quality: 75,
destinationType: Camera.DestinationType.FILE_URL,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: false,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 720,
targetHeight: 1280,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false,
correctOrientation: true
};
return $cordovaCamera.getPicture(options).then(upload);
function upload(filePath) {
return $cordovaFileTransfer.upload('http://example.com', filePath, {
fileKey: 'file',
fileName: 'example.jpeg',
mimeType: 'image/jpeg'
});
}
Upvotes: 3