在我的 android cordova/phonegap v2.8 应用程序中,我试图将图像上传到我的 amazon s3 存储桶。我已经有了执行上传的代码。
function upload_media(imgURI) {
var options = new FileUploadOptions();
options.fileKey="file";
var time = new Date().getTime();
var fileName = time+".jpg";
options.fileName = fileName;
options.mimeType ="image/jpeg";
options.chunkedMode = false;
var uri = encodeURI("http://<your bucket name>.s3.amazonaws.com/");
var policyDoc = '<Base 64 policy doc>';
var signature = '<Generated Signature>';
var params = {
"key": "media/"+fileName,
"AWSAccessKeyId": "<Your AWS Access Key>",
"acl": "public-read",
"policy": policyDoc,
"signature": signature,
"Content-Type": ""
};
options.params = params;
var ft = new FileTransfer();
ft.upload(imgURI, uri, function() {
console.log("Success! :)");
},
function() {
console.log("Failure! :(");
}, options);
}
但我不知道在上面的脚本中获取并包含签名和策略文档。谢谢