4

I'm trying to figure out how to incorporate S3 with dragonfly. This gem works locally, but because I'm using Heroku, the files gets deleted... so, I'm thinking I need to implement it into S3.

I'm using this gem: dragonfly-s3_data_store where my dragonfly.rb looks like this:

/config/initializers/dragonfly.rb

require 'dragonfly'
require 'dragonfly/s3_data_store'

# Configure
Dragonfly.app.configure do
  plugin :imagemagick

  url_format "/media/:job/:name"

  datastore :s3,
    bucket_name: 'thelab',
    access_key_id: '{my access key}',
    secret_access_key: '{my secret key}',
    region: "us-west-1"
end

... #more code

This is my error when I'm trying to upload an image:

hostname "thelab.thelab.s3-us-west-1.amazonaws.com" does not match the server certificate (OpenSSL::SSL::SSLError)

I'm not sure what's causing the issue, but also on my console, I see this popping up:

[fog][WARNING] fog: followed redirect to thelab.s3-us-west-2.amazonaws.com, connecting to the matching region will be more performant

There's inconsistency here... I've also tried to switch the region to us-west-2, but I still get the same errors and warning signs.

form:

= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f|
  = f.file_field :image
  = f.button :submit, "Save changes"

And of course, the model, in this case user.rb, has this:

dragonfly_accessor :image

Am I missing anything else that needs to be configured?

Also, my CORS Configuration for thelab bucket

<CORSConfiguration>
    <CORSRule>
        <AllowedOrigin>*</AllowedOrigin>
        <AllowedMethod>GET</AllowedMethod>
        <MaxAgeSeconds>3000</MaxAgeSeconds>
        <AllowedHeader>Authorization</AllowedHeader>
    </CORSRule>
</CORSConfiguration>
hellomello
  • 8,219
  • 39
  • 151
  • 297

0 Answers0