Skip to content

Example of setting up "s3_direct_upload" with Server Side Encryption on Amazon S3

Enrique Carlos Mogollan edited this page Nov 10, 2015 · 1 revision

Step: 1 Add the following option to your s3_uploader_form call to generate the policy properly:

conditions: [{ 'x-amz-server-side-encryption' => 'AES256'}]

Step: 2 Then, add the following inside your form so S3 knows you want to encrypt:

<%= hidden_field_tag 'x-amz-server-side-encryption', 'AES256' %>

Example:

<div>
  <%= s3_uploader_form callback_url: "AFTER_UPLOAD_CALLBACK", max_file_size: 20.megabytes, class: "neat upload-form", conditions: [{ 'x-amz-server-side-encryption' => 'AES256'}] do %>
    <%= hidden_field_tag 'x-amz-server-side-encryption', 'AES256' %>
    <fieldset>
      <legend>Upload Document</legend>
      <div class="browse btn-group">
        <a class="btn btn-primary">
          Browse...
          <%= file_field_tag :file, multiple: false %>
        </a>
      </div>
    </fieldset>
  <% end %>
</div>

The information presented here has been extracted from comments here: https://github.com/waynehoover/s3_direct_upload/issues/138 Thank you @ykessler, @elsurudo

Clone this wiki locally