Android 文件上传问题phonegap应用程序到Amazon s3
我收到JAVA.io.IOException接收到服务器错误。下面是从phonegap应用程序上传文件到AmazonS3的代码 下面是链接中的示例: var s3Uploader=(函数(){ }()) 变量$img=$('img','.scroller')Android 文件上传问题phonegap应用程序到Amazon s3,android,cordova,amazon-web-services,amazon-s3,Android,Cordova,Amazon Web Services,Amazon S3,我收到JAVA.io.IOException接收到服务器错误。下面是从phonegap应用程序上传文件到AmazonS3的代码 下面是链接中的示例: var s3Uploader=(函数(){ }()) 变量$img=$('img','.scroller') var s3URI = encodeURI("http://***********.s3-website-us-west-2.amazonaws.com/"); policyBase64 = "base64 string remo
var s3URI = encodeURI("http://***********.s3-website-us-west-2.amazonaws.com/");
policyBase64 = "base64 string removed";
signature = "base64 string removed";
awsKey = 'AWSAccessKeyId removed';
acl = "public-read";
function upload(imageURI, fileName) {
var deferred = $.Deferred()
var ft = new FileTransfer();
options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = fileName;
options.mimeType = "image/jpeg";
options.chunkedMode = true;
options.params = {
"key": fileName,
"AWSAccessKeyId": awsKey,
"acl": acl,
"policy": policyBase64,
"signature": signature,
"Content-Type": "image/jpeg"
};
ft.upload(imageURI, s3URI,
function (e) {
console.log(e);
deferred.resolve(e);
},
function (e) {
console.log(JSON.stringify(e));
deferred.reject(e);
}, options);
return deferred.promise();
}
return {
upload: upload
}
takePicture = function (e) {
var options = {
quality: 45,
targetWidth: 1000,
targetHeight: 1000,
destinationType: Camera.DestinationType.FILE_URI,
encodingType: Camera.EncodingType.JPEG,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY
};
navigator.camera.getPicture(
function (imageURI) {
alert(imageURI);
alert(imageURI);
$img.attr('src', imageURI);
var fileName = "" + (new Date()).getTime() + ".jpg";
s3Uploader.upload(imageURI, fileName)
.done(function () {
alert("S3 upload succeeded");
})
.fail(function () {
alert("S3 upload failed");
});
},
function (message) {
alert(JSON.stringify(message));
}, options);
return false;
};
$('.camera-btn').on('click', takePicture);