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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi I want to upload and image on s3 using ionic