好吧,我使用carrierwave並生成版本(縮略圖)。 存儲後端是Amazon S3。Carrierwave沒有從S3中刪除版本,只有原始文件
class Image < ActiveRecord::Base
mount_uploader :attachment, ImageUploader
end
當我打電話Image.find(1).destroy,原始文件被從S3移除:
但它的一個版本劇照有:
我懷疑該方法def full_filename(for_file)
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
include CarrierWave::MiniMagick
include CarrierWaveDirect::Uploader
def store_dir
"assets"
end
def cache_dir
"#{Rails.root}/tmp/images"
end
version :square do
process resize_to_fill: [200, 200]
def full_filename(for_file)
ext = File.extname(for_file)
base_name = for_file.chomp(ext)
[base_name, version_name].compact.join('_') + ".jpg"
end
end
end
在此先感謝!
我也推薦閱讀官方的CarrierWave Github頁面:https://github.com/carrierwaveuploader/carrierwave – HackerKarma