Adding uploaded pictures fro Heroku to AWS S3 Bucket

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding uploaded pictures fro Heroku to AWS S3 Bucket

David Merrick
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 'mybucketName.s3.amazonaws.com'
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/
end

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

<%= render 'home/jumbo' unless user_signed_in? %>
<div class = 'center'>
<%= will_paginate @pins%>
</div>
<div id="container" class="transitions-enabled">
<% @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><%= pin.user.name if pin.user %></strong>
</div>
    <%#= 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?' } %>
    </div>
    <% end %>
</div>
</div>
<% end %>
</div>

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

Cheers Dave


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2d2750bb-4148-4687-8d9f-d225a3779e4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Adding uploaded pictures fro Heroku to AWS S3 Bucket

Hassan Schroeder-2
On Wed, Feb 6, 2019 at 8:31 PM David Merrick <[hidden email]> wrote:
>
> Current errors 500 Internal Server Error and Aws::S3::Errors::AccessDenied

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?

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yBYDpgVFi%3DpSa5%3Du%2B-tR-md48xkEbdhfj%2BCzTsjEEPOpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Adding uploaded pictures fro Heroku to AWS S3 Bucket

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

On Thu, Feb 7, 2019 at 6:07 PM Hassan Schroeder <[hidden email]> wrote:
On Wed, Feb 6, 2019 at 8:31 PM David Merrick <[hidden email]> wrote:
>
> Current errors 500 Internal Server Error and Aws::S3::Errors::AccessDenied

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?

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yBYDpgVFi%3DpSa5%3Du%2B-tR-md48xkEbdhfj%2BCzTsjEEPOpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


--
Dave Merrick

Daves Web Designs

Website http://www.daveswebdesigns.co.nz

Email [hidden email]

Ph   03 216 2053

Cell 027 3089 169

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2B%3DMcKb_qF%2B3XULxV6Xg08QBOfhRfLFqa1hkcsQJ2GsY9XOseQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

log2.jpg (18K) Download Attachment
log0.jpg (101K) Download Attachment
log3.jpg (21K) Download Attachment
log1.jpg (57K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Adding uploaded pictures fro Heroku to AWS S3 Bucket

Ryan-2
In reply to this post by David Merrick
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.


On Wednesday, February 6, 2019 at 8:31:10 PM UTC-8, David Merrick wrote:
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 '<a href="http://mybucketName.s3.amazonaws.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FmybucketName.s3.amazonaws.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGx9ZJFQdMxe4_RKuEiPh8iVBM_LA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FmybucketName.s3.amazonaws.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGx9ZJFQdMxe4_RKuEiPh8iVBM_LA&#39;;return true;">mybucketName.s3.amazonaws.com'
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/
end

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

<%= render 'home/jumbo' unless user_signed_in? %>
<div class = 'center'>
<%= will_paginate @pins%>
</div>
<div id="container" class="transitions-enabled">
<% @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><%= <a href="http://pin.user.name" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fpin.user.name\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHZqHNyusaZGYoYJb2MF6fBgxWaeQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fpin.user.name\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHZqHNyusaZGYoYJb2MF6fBgxWaeQ&#39;;return true;">pin.user.name if pin.user %></strong>
</div>
    <%#= 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?' } %>
    </div>
    <% end %>
</div>
</div>
<% end %>
</div>

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

Cheers Dave


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0bc96cca-11e0-449a-9652-53a359bb799d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Adding uploaded pictures fro Heroku to AWS S3 Bucket

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

On Thu, Feb 7, 2019 at 9:05 PM Ryan <[hidden email]> wrote:
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.


On Wednesday, February 6, 2019 at 8:31:10 PM UTC-8, David Merrick wrote:
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 'mybucketName.s3.amazonaws.com'
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/
end

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

<%= render 'home/jumbo' unless user_signed_in? %>
<div class = 'center'>
<%= will_paginate @pins%>
</div>
<div id="container" class="transitions-enabled">
<% @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><%= pin.user.name if pin.user %></strong>
</div>
    <%#= 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?' } %>
    </div>
    <% end %>
</div>
</div>
<% end %>
</div>

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

Cheers Dave


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0bc96cca-11e0-449a-9652-53a359bb799d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Dave Merrick

Daves Web Designs

Website http://www.daveswebdesigns.co.nz

Email [hidden email]

Ph   03 216 2053

Cell 027 3089 169

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2B%3DMcKby7nYRSK_3PMMki_qEYHvqc8PR17%3DvQVQiKgShZdeqMg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Adding uploaded pictures fro Heroku to AWS S3 Bucket

Walter Lee Davis

> On Feb 7, 2019, at 3:25 AM, David Merrick <[hidden email]> wrote:
>
> I'm not using carrier wave. I'm using paperclip.

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

Walter

>
> On Thu, Feb 7, 2019 at 9:05 PM Ryan <[hidden email]> wrote:
> 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.
>
>
> On Wednesday, February 6, 2019 at 8:31:10 PM UTC-8, David Merrick wrote:
> 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 'mybucketName.s3.amazonaws.com'
> 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/
> end
>
> my index.html.erb to view my pins has this code
>
> <%= render 'home/jumbo' unless user_signed_in? %>
> <div class = 'center'>
> <%= will_paginate @pins%>
> </div>
> <div id="container" class="transitions-enabled">
> <% @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><%= pin.user.name if pin.user %></strong>
> </div>
>    <%#= 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?' } %>
>    </div>
>    <% end %>
> </div>
> </div>
> <% end %>
> </div>
>
> What else am I missing to connect Heroku to AWS S3 Bucket to upload and store images?
>
> Cheers Dave
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0bc96cca-11e0-449a-9652-53a359bb799d%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> Dave Merrick
>
> Daves Web Designs
>
> Website http://www.daveswebdesigns.co.nz
>
> Email [hidden email]
>
> Ph   03 216 2053
>
> Cell 027 3089 169
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2B%3DMcKby7nYRSK_3PMMki_qEYHvqc8PR17%3DvQVQiKgShZdeqMg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/865CEC38-F174-4E4E-81A9-17726AC8E87C%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Adding uploaded pictures fro Heroku to AWS S3 Bucket

David Merrick
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


On Fri, Feb 8, 2019 at 2:40 AM Walter Lee Davis <[hidden email]> wrote:

> On Feb 7, 2019, at 3:25 AM, David Merrick <[hidden email]> wrote:
>
> I'm not using carrier wave. I'm using paperclip.

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

Walter

>
> On Thu, Feb 7, 2019 at 9:05 PM Ryan <[hidden email]> wrote:
> 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.
>
>
> On Wednesday, February 6, 2019 at 8:31:10 PM UTC-8, David Merrick wrote:
> 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 'mybucketName.s3.amazonaws.com'
> 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/
> end
>
> my index.html.erb to view my pins has this code
>
> <%= render 'home/jumbo' unless user_signed_in? %>
> <div class = 'center'>
> <%= will_paginate @pins%>
> </div>
> <div id="container" class="transitions-enabled">
>       <% @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><%= pin.user.name if pin.user %></strong>
>                               </div> 
>                           <%#= 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?' } %>
>                           </div>
>                           <% end %>                                           
>                       </div>
>               </div>
>       <% end %>               
> </div>
>
> What else am I missing to connect Heroku to AWS S3 Bucket to upload and store images?
>
> Cheers Dave
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0bc96cca-11e0-449a-9652-53a359bb799d%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> Dave Merrick
>
> Daves Web Designs
>
> Website http://www.daveswebdesigns.co.nz
>
> Email [hidden email]
>
> Ph   03 216 2053
>
> Cell 027 3089 169
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2B%3DMcKby7nYRSK_3PMMki_qEYHvqc8PR17%3DvQVQiKgShZdeqMg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/865CEC38-F174-4E4E-81A9-17726AC8E87C%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


--
Dave Merrick

Daves Web Designs

Website http://www.daveswebdesigns.co.nz

Email [hidden email]

Ph   03 216 2053

Cell 027 3089 169

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2B%3DMcKYKiP%2BkcXHAh0EfXzAYPBmvoYBqssmYfek4%2B7VZ%2BL9M1g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Adding uploaded pictures fro Heroku to AWS S3 Bucket

David Merrick
In reply to this post by Walter Lee Davis
When  I click on the URL  for the image I get this message

<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>8866EFBB969E901F</RequestId>
<HostId>
2E/t/DqGuJMiOcZIaq/WVU8F0KjFRQq91r+bNZz3OWigBEMOczczJ2aFrnHfXn4wQ7E/A7WNPP4=
</HostId>
</Error>

Cheers Dave

On Fri, Feb 8, 2019 at 2:40 AM Walter Lee Davis <[hidden email]> wrote:

> On Feb 7, 2019, at 3:25 AM, David Merrick <[hidden email]> wrote:
>
> I'm not using carrier wave. I'm using paperclip.

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

Walter

>
> On Thu, Feb 7, 2019 at 9:05 PM Ryan <[hidden email]> wrote:
> 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.
>
>
> On Wednesday, February 6, 2019 at 8:31:10 PM UTC-8, David Merrick wrote:
> 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 'mybucketName.s3.amazonaws.com'
> 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/
> end
>
> my index.html.erb to view my pins has this code
>
> <%= render 'home/jumbo' unless user_signed_in? %>
> <div class = 'center'>
> <%= will_paginate @pins%>
> </div>
> <div id="container" class="transitions-enabled">
>       <% @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><%= pin.user.name if pin.user %></strong>
>                               </div> 
>                           <%#= 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?' } %>
>                           </div>
>                           <% end %>                                           
>                       </div>
>               </div>
>       <% end %>               
> </div>
>
> What else am I missing to connect Heroku to AWS S3 Bucket to upload and store images?
>
> Cheers Dave
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0bc96cca-11e0-449a-9652-53a359bb799d%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> Dave Merrick
>
> Daves Web Designs
>
> Website http://www.daveswebdesigns.co.nz
>
> Email [hidden email]
>
> Ph   03 216 2053
>
> Cell 027 3089 169
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2B%3DMcKby7nYRSK_3PMMki_qEYHvqc8PR17%3DvQVQiKgShZdeqMg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/865CEC38-F174-4E4E-81A9-17726AC8E87C%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


--
Dave Merrick

Daves Web Designs

Website http://www.daveswebdesigns.co.nz

Email [hidden email]

Ph   03 216 2053

Cell 027 3089 169

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2B%3DMcKZ8Rk9FMM1CgK0AL8VRS%2B_Y4AnHyTLAJF0JmRWqGzXRSg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Adding uploaded pictures fro Heroku to AWS S3 Bucket

Hassan Schroeder-2
On Thu, Feb 7, 2019 at 12:16 PM David Merrick <[hidden email]> wrote:

>
> When  I click on the URL  for the image I get this message
>
> <Error>
> <Code>AccessDenied</Code>
> <Message>Access Denied</Message>
> <RequestId>8866EFBB969E901F</RequestId>
> <HostId>
> 2E/t/DqGuJMiOcZIaq/WVU8F0KjFRQq91r+bNZz3OWigBEMOczczJ2aFrnHfXn4wQ7E/A7WNPP4=
> </HostId>
> </Error>

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

Good luck!
--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yDgwrrtpF5x8S%3D66%2B%2BWrA%2BWxNCWdMwxT0x4py0BsQ185g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Adding uploaded pictures fro Heroku to AWS S3 Bucket

David Merrick
Thanks time to read and ask more questions later.

Cheers Dave

On Fri, Feb 8, 2019 at 10:27 AM Hassan Schroeder <[hidden email]> wrote:
On Thu, Feb 7, 2019 at 12:16 PM David Merrick <[hidden email]> wrote:
>
> When  I click on the URL  for the image I get this message
>
> <Error>
> <Code>AccessDenied</Code>
> <Message>Access Denied</Message>
> <RequestId>8866EFBB969E901F</RequestId>
> <HostId>
> 2E/t/DqGuJMiOcZIaq/WVU8F0KjFRQq91r+bNZz3OWigBEMOczczJ2aFrnHfXn4wQ7E/A7WNPP4=
> </HostId>
> </Error>

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

Good luck!
--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yDgwrrtpF5x8S%3D66%2B%2BWrA%2BWxNCWdMwxT0x4py0BsQ185g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


--
Dave Merrick

Daves Web Designs

Website http://www.daveswebdesigns.co.nz

Email [hidden email]

Ph   03 216 2053

Cell 027 3089 169

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2B%3DMcKZ8Q9EA%2BBfa%2B6CUAS87yaKGuy9ZaNcmgELzDJvRj9asMQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Adding uploaded pictures fro Heroku to AWS S3 Bucket

David Merrick
In reply to this post by Hassan Schroeder-2
I need help setting up a Bucket Policy please. I find this http://awspolicygen.s3.amazonaws.com/policygen.html
to hard to work out.

Cheers Dave


On Fri, Feb 8, 2019 at 10:27 AM Hassan Schroeder <[hidden email]> wrote:
On Thu, Feb 7, 2019 at 12:16 PM David Merrick <[hidden email]> wrote:
>
> When  I click on the URL  for the image I get this message
>
> <Error>
> <Code>AccessDenied</Code>
> <Message>Access Denied</Message>
> <RequestId>8866EFBB969E901F</RequestId>
> <HostId>
> 2E/t/DqGuJMiOcZIaq/WVU8F0KjFRQq91r+bNZz3OWigBEMOczczJ2aFrnHfXn4wQ7E/A7WNPP4=
> </HostId>
> </Error>

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

Good luck!
--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yDgwrrtpF5x8S%3D66%2B%2BWrA%2BWxNCWdMwxT0x4py0BsQ185g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


--
Dave Merrick

Daves Web Designs

Website http://www.daveswebdesigns.co.nz

Email [hidden email]

Ph   03 216 2053

Cell 027 3089 169

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2B%3DMcKYTuE5mPzJD7hRzq6JkbZitn4NZ9MYdJJ_YsLBF-pMPVw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.