我使用延遲迴形針以及直接上傳到S3。我的模型被稱爲Photo
,其附件是image
。使用帶有延遲迴形針的S3直接上傳
使用JavaScript中的圖片將圖片上傳到S3。該文件存儲在Paperclip希望找到原始圖像的位置,並將文件詳細信息保存到隱藏字段中。當提交表單時,這些屬性被寫入到照片模式:
image_file_name image_file_size image_content_type
因爲寫僅憑這些屬性似乎不是足以觸發延遲迴形針處理圖像,Photo.save
後,我打電話Photo.image.reprocess!
這會得到DelayedPaperclip來創建一個新的成功處理圖像的Sidekiq作業。
的問題是,當我在PhotosController
調用Photo.save
,將文件複製到從S3一temp
目錄,然後再返回到S3。出現這種情況的工作,在和阻止:
[paperclip] copying image_assets/grab-original.tiff to local file /var/folders/bv/x495g9g10m7119680c9ssqmr0000gn/T/94943834d26bcb8b471f4eeb2a7f899d20141125-3895-1oqom7l
[AWS S3 200 2.601589 0 retries] get_object(:bucket_name=>"example-com-development",:key=>"image_assets/grab-original.tiff")
[paperclip] saving image_assets/grab-original.tiff
[AWS S3 200 2.47114 0 retries] put_object(:acl=>:public_read,:bucket_name=>"example-com-development",:cache_control=>"max-age=29030400",:content_length=>534472,:content_type=>"image/tiff",:data=>Paperclip::AttachmentAdapter: grab.tiff,:key=>"image_assets/grab-original.tiff")
爲什麼回形針複製文件下來,然後再返回?