[英]Upload Image to Amazon S3 (How to get Signature and Policy Doc)
In my android cordova/phonegap v2.8 app am trying to upload an image to my amazon s3 bucket. 在我的android cordova / phonegap v2.8应用程序中,我试图将图像上传到我的Amazon s3存储桶。 I already have the code that performs the upload.
我已经有执行上传的代码。
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);
}
But i don't know to get and include the signature and policy doc in the above script. 但我不知道在上述脚本中获取并包括签名和策略文档。 Thanks
谢谢
I had this same issue a while ago while working with Cordova. 前一段时间,我在与Cordova合作时遇到了同样的问题。 This is a helpful link that helped me make my Python Script that generates a policy and signature.
这是一个有用的链接,它帮助我制作了生成策略和签名的Python脚本。 I hope it's helpful!
希望对您有所帮助!
Generating Amazon S3 CORS signature with Python 使用Python生成Amazon S3 CORS签名
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.