I'm trying to figure out how to turn on S3 with a dragonfly. This stone works locally, but since I use Heroku, the files are deleted ... so I think I need to implement it in S3.
I use this gem: dragonfly-s3_data_store , where my dragonfly.rb looks like this:
/config/initializers/dragonfly.rb
require 'dragonfly'
require 'dragonfly/s3_data_store'
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
...
This is my mistake when I try 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 causes the problem, 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 is inconsistency here ... I also tried to switch the region to us-west-2, but I still get the same errors and warning signs.
the 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 the following:
dragonfly_accessor :image
Am I missing something else I need to configure?
, CORS thelab
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
</CORSConfiguration>