Created
March 2, 2016 18:29
-
-
Save Aupajo/e1ead99b677b307d03ed to your computer and use it in GitHub Desktop.
Uploading to S3 without a server in Rails
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
<% post = Aws::S3::Bucket.new(ENV.fetch('AWS_S3_BUCKET')).presigned_post(key: 'uploads/${filename}', acl: 'public-read') %> | |
<%= form_tag(post.url, id: 'uploader', multipart: true, authenticity_token: false, enforce_utf8: false) do %> | |
<% post.fields.each do |name, value| %> | |
<%= text_field_tag name, value %> | |
<% end %> | |
<% # Must be last field %> | |
<%= file_field_tag :file %> | |
<input type="submit" value="Upload"> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment