Created
November 27, 2012 19:47
-
-
Save devgeeks/4156546 to your computer and use it in GitHub Desktop.
S3 direct upload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var options = new FileUploadOptions(); | |
options.fileKey="fileupload"; | |
var time = new Date().getTime(); | |
var userId = getUserId(); // In my case, Parse.User.current().id; | |
var fileName = userId+"-"+time+".jpg"; | |
options.fileName = fileName; | |
options.mimeType ="image/jpeg"; | |
options.chunkedMode = false; | |
var uri = encodeURI("https://BUCKET_NAME.s3.amazonaws.com/"); | |
var policyDoc = "POLICY_DOC_GOES_HERE"; | |
var signature = "SIGNATURE_GOES_HERE"; | |
var params = { | |
"key": "uploads/"+fileName, | |
"AWSAccessKeyId": "ACCESS_KEY_GOES_HERE", | |
"acl": "public-read", | |
"policy": policyDoc, | |
"signature": signature, | |
"Content-Type": "image/jpeg" | |
}; | |
options.params = params; | |
var ft = new FileTransfer(); | |
ft.upload(imageURI, uri, uploadSuccess, uploadFail, options); |
@droizman : I just used the Ruby example from http://aws.amazon.com/articles/1434
Hi I want to upload and image on s3 using ionic
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just getting into this space and trying to find out how to generate the signature and a policy doc. Can you recommend a method?