I have created an app where Im trying to capture a video and upload that video directly to AWS S3. Capturing the video takes place, but uploading is failing. Infact I don’t see any error messages on the phone screen even though I have alert messages.
Please find the sample code below my controller:
$scope.takePicture = function() {
var options = {
quality: 45,
targetWidth: 1000,
targetHeight: 1000,
destinationType: Camera.DestinationType.FILE_URI,
encodingType: Camera.EncodingType.JPEG,
sourceType: Camera.PictureSourceType.CAMERA,
};
navigator.camera.getPicture(
function (imageURI) {
var fileName = "" + (new Date()).getTime() + ".jpg"; // consider a more reliable way to generate unique ids
var s3URI = encodeURI("https://bucket_name.s3.amazonaws.com/"),
policyBase64 = "policy_base",
signature = "signature",
awsKey = 'AWS_Key',
acl = "public-read";
alert("imageURI: "+ imageURI+" fileName: "+fileName);
var deferred = $.Deferred(),
ft = new FileTransfer(),
options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = fileName;
options.mimeType = "image/jpeg";
options.chunkedMode = false;
options.params = {
"key": fileName,
"AWSAccessKeyId": awsKey,
"acl": acl,
"policy": policyBase64,
"signature": signature,
"Content-Type": "image/jpeg"
};
$cordovaFileTransfer.upload(s3URI, imageURI, options).then(function(result) {
console.log("SUCCESS: " + JSON.stringify(result.response));
}, function(err) {
console.log("ERROR: " + JSON.stringify(err));
}, function (progress) {
// constant progress updates
});
},
function (message) {
// We typically get here because the use canceled the photo operation. Fail silently.
}, options);
return false;
};
Any help is greatly appreciated. thanks!