Skip to content

Instantly share code, notes, and snippets.

@fivemini
Created October 14, 2013 15:53
Show Gist options
  • Save fivemini/6977860 to your computer and use it in GitHub Desktop.
Save fivemini/6977860 to your computer and use it in GitHub Desktop.
require 'aws-sdk'
aws = AWS.config(access_key_id: ENV['AWS_ACCESS_KEY'], secret_access_key: ENV['AWS_SECRET_KEY'])
s3 = AWS::S3.new
bucket = s3.buckets[ARGV[0]]
form = bucket.objects[ARGV[1]].presigned_post
hidden_inputs = form.fields.map do |(name, value)|
%(<input type="hidden" name="#{name}" value="#{value}" />)
end
puts <<-END
<form action="#{form.url}" method="post" enctype="multipart/form-data">
#{hidden_inputs.join}
<input type="file" name="file" />
<input type="submit" value="upload">
</form>
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment