开发者

How to set Dragonfly for use with S3?

开发者 https://www.devze.com 2023-03-09 01:27 出处:网络
In my initializers/dragonfly.rb I put this: require \'dragonfly/rails/images\' app = Dragonfly[:app_name]

In my initializers/dragonfly.rb I put this:

require 'dragonfly/rails/images'

app = Dragonfly[:app_name]
app.datastore = Dragonfly::DataStorage::S3DataStore.new({
  :bucket_name        => 'bucket_name',
  :access_key_id      => 'key...',
  :secret_access_key  => 'key...'
})

But does开发者_如何学JAVAn't work, app still saving files in local. What I missing?

EDIT: I changed Dragonfly[:app_name] to Dragonfly[:images] and it works. Why I need to set :images, if I can upload any type of files?


When you use the 'dragonfly/rails/images' default settings, it sets Dragonfly[:images] as the app name. See the Dragonfly documentation for how you customize it inside of config/initializers/dragonfly.rb. You could do something like this:

  require 'dragonfly'

  app = Dragonfly[:app_name]
  app.configure_with(:imagemagick)
  app.configure_with(:rails)

  # ... etc
0

精彩评论

暂无评论...
验证码 换一张
取 消