Skip to content

Instantly share code, notes, and snippets.

@smokeymonkey
Created July 18, 2014 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smokeymonkey/45811ed2e9126a4477e2 to your computer and use it in GitHub Desktop.
Save smokeymonkey/45811ed2e9126a4477e2 to your computer and use it in GitHub Desktop.
require 'aws-sdk'
ACCESS_KEY_ID ="your_access_key"
SECRET_ACCESS_KEY="your_secret_access_key"
AWS.config(
:access_key_id => ACCESS_KEY_ID,
:secret_access_key => SECRET_ACCESS_KEY
)
s3 = AWS::S3.new
bucket = s3.buckets['your_bucket_name']
presign = bucket.presigned_post(:key => "your_key")
puts presign.url.to_s + presign.fields['key'] + "?" \
+ "Expires=86400" \
+ "AWSAccessKeyId=" + presign.fields['AWSAccessKeyId'] \
+ "Signature=" + presign.fields['signature']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment