s3 datastore behaves different than file store

40 views
Skip to first unread message

Peter Black

unread,
Nov 4, 2015, 6:29:20 PM11/4/15
to Dragonfly
Dragonfly is setup on my server and runs great! We are moving to amazon s3 and im running in to some problems.

  url_format "/media/:job/:name.:ext"
  if Rails.env.production?
    datastore :s3,
      bucket_name: 'bucket',
      access_key_id: 'some access key....',
      secret_access_key: 'some secret key....',
      region: 'us-west-1',
      storage_headers: {'x-amz-acl' => 'private'},
      url_scheme: 'https',
  else
    datastore :file,
      root_path: Rails.root.join('public/system/dragonfly', Rails.env),
      server_root: Rails.root.join('public')
  end


1) Images with the extension '.dcm' work fine in the regular file store but when i turn on s3 the thumbnails and regular images do not work. I have defined:
    mime_type 'dcm', 'image/dicom'
  But that does not seem to do anything.

2) Some of my models do not have image_name. When you download them through the regular file store it works. Once S3 is on, it no longer knows how to handle them. Examples include 'docx', 'jpg'. I have tried editing the initializer to solve this problem:

  define_url do |app, job, opts|
    file_name = nil
    if job.uid.present?
      file_name = File.basename(job.uid)
    end

    if file_name.blank?
      app.server.url_for(job, opts)
    else
      app.server.url_for(job, :name => file_name[27, file_name.length])
    end
  end

Then the file is downloaded as: '/media/W1siZiIsIjIwMTUvMDkvMDQvMDhfNDVfMzFfNTMwX3R1bWJscl9tOGg2cWJjNldyMXJzbXdzM28xXzUwMC5naWYiXSxbInAiLCJ0aHVtYiIyIjEwMHgxMDAjIl1d/my_file.gif?sha=7e581ee91f732844'

However, this does not solve all of the issues. Is the only solution to add file_name to the model?

Mark Evans

unread,
Nov 7, 2015, 6:35:02 AM11/7/15
to dragonf...@googlegroups.com
1) Images with the extension '.dcm' work fine in the regular file store but when i turn on s3 the thumbnails and regular images do not work.
What is the code you're using to generate the urls? And is there anything dragonfly-related showing up in the logs?

 
2) Some of my models do not have image_name. When you download them through the regular file store it works. Once S3 is on, it no longer knows how to handle them.
What do you mean by it doesn't know how to handle them? Is there a particular error showing up?
 
cheers
Reply all
Reply to author
Forward
0 new messages