jrgifford / delayed_paperclip

Process your Paperclip attachments in the background with delayed_job or Resque.
http://www.jstorimer.com/ruby/2010/01/30/delayed-paperclip.html
MIT License
404 stars 155 forks source link

Creates original style twice on S3 #215

Open davidalejandroaguilar opened 6 years ago

davidalejandroaguilar commented 6 years ago

Hi,

For some reason, adding this process_in_background call will create 2 original files in my S3 account; so when I delete the asset, 1 file stays there. What could be causing this? This is my Asset file:

class Asset < ApplicationRecord
  paperclip_options = {
    styles: { hero: '1200x1200>', large: '333x333#', medium: '300x300>', thumb: '200x200#' },
    url: "/system/assets/images/:style-:filename-:hash.:extension",
    hash_secret: ENV['PAPERCLIP_SALT']
  }

  has_attached_file :image, paperclip_options

  unless Rails.env.test?
    paperclip_options.merge!({
      storage: :s3,
      s3_credentials: File.expand_path('../../../aws.yml', __FILE__),
      bucket: ENV['S3_BUCKET_NAME'],
      s3_region: ENV['AWS_REGION'],
      s3_host_name: "s3-#{ENV['AWS_REGION']}.amazonaws.com",
      processors: [:compression]
    })
  end

  process_in_background :image, processing_image_url: -> (attachment) {
    ActionController::Base.helpers.image_path('loading.gif')
  }
end

Using: delayed_paperclip (3.0.1) paperclip (5.2.1) paperclip-compression (1.0.1)