Home Redirect after uploading to S3 from rails app
Reply: 1

Redirect after uploading to S3 from rails app

Jeremy Thomas
1#
Jeremy Thomas Published in 2018-02-13 22:39:52Z

I have a simple file upload field:"

<form action="<%= @post.url %>" method="post" enctype="multipart/form-data" id="new_file_tag">
    <% @post.fields.each do |name, value| %>
      <input type="hidden" name="<%= name %>" value="<%= value %>"/>
    <% end %>
    <input type="file" name="file"/>
    <input type="submit" class="btn btn-awaken btn-sm">
</form>

that I took from the S3 online docs. The only issue is that it redirects to the S3 object after upload rather than simply returning to the same page.

How can I change the form to accomplish this? I tried changing the form to rails helpers, but the upload would fail due to the automatic accept-charset="UTF-8" param.

Anthony L
2#
Anthony L Reply to 2018-02-14 04:10:01Z

The form should contain a field for the success_action_redirect option, which has the value of the URL you would like to redirect the user to following a successful post.

https://docs.aws.amazon.com/sdkforruby/api/Aws/S3/PresignedPost.html#success_action_redirect-instance_method

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.597888 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO