Adding uploaded pictures fro Heroku to AWS S3 Bucket

Current errors 500 Internal Server Error and Aws::S3::Errors::AccessDenied

My paperclip.rb in config/initializers is below

Paperclip::Attachment.default_options[:url] = ‘:s3_domain_url’ # Should this line have instead of this ‘:s3_domain_url’ this ‘

Paperclip::Attachment.default_options[:path] = ‘/:class/:attachment/:id_partition/:style/:filename’

my production.rb in config/environments this code at the end

config.paperclip_defaults = {

storage: :s3,

s3_credentials: {

bucket: ENV.fetch(‘S3_BUCKET_NAME’),

access_key_id: ENV.fetch(‘AWS_ACCESS_KEY_ID’),

secret_access_key: ENV.fetch(‘AWS_SECRET_ACCESS_KEY’),

s3_region: ENV.fetch(‘AWS_REGION’),



My pin.rb in models has this code

Class Pin < ApplicationRecord

belongs_to :user

has_attached_file :image, styles: { medium: "300x300#", thumb: "100x100>" }

validates_attachment_content_type :image, content_type: /\Aimage/.*\z/


my index.html.erb to view my pins has this code

<%= render ‘home/jumbo’ unless user_signed_in? %>

<%= will_paginate @pins%>

<% @pins.each do |pin| %>

	<div class='box'>

		<div class="panel panel-default">

		    <%= link_to image_tag(pin.image.url(:medium)),pin %><br>

		    <div class="panel-body">

			    <%= pin.description %><br>

			    <strong><%= if pin.user %></strong>


		    <%#= link_to 'Show', pin %>

		    <% if pin.user == current_user %>

		    <div class="panel-footer">

		      <%= link_to 'Edit', edit_pin_path(pin) %>

		      <%= link_to 'Destroy', pin, method: :delete, data: { confirm: 'Are you sure?' } %>


		    <% end %>



<% end %>

What else am I missing to connect Heroku to AWS S3 Bucket to upload and store images?

Cheers Dave

Can you manually upload an image to S3 via the AWS CLI using
those credentials?

Can you view an uploaded image from that bucket in a browser?

I can log into my AWS account and can upload images but can’t view them. Attached are some screenshots.




Hi David,

Check out this SO article that references S3 bucket permissions. Carrierwave needs to be able to write to the S3 bucket. Ensure your bucket has Put permissions.

I’m not using carrier wave. I’m using paperclip.

I'm not using carrier wave. I'm using paperclip.

Yes, but the same rules apply (on the S3 side) for any attachment system.


Hi Once I enable pop ups for aws I can now upload and view images when logged into AWS .

Any suggestions for the bucket?

Cheers Dave

When I click on the URL for the image I get this message


Access Denied



Cheers Dave

So your bucket isn't configured for public http(s) access; time to dig
into the S3 config...

Good luck!

Thanks time to read and ask more questions later.

Cheers Dave

I need help setting up a Bucket Policy please. I find this

to hard to work out.

Cheers Dave