我使用組合Heroku + Amazon S3 + Paperclip gem來上傳文件。它正在工作,但上傳本身非常緩慢。Heroku上的Rails + Paperclip非常慢
我試圖購買額外的賽道和一點點更新模型:
class Image < ActiveRecord::Base
belongs_to :imageable, :polymorphic => true
belongs_to :user
belongs_to :album
attr_accessible :caption, :title, :image, :image_file_name, :user_id, :album_id
has_attached_file :image,
:styles => { :tiny => '100x100>',
:original => "900x900>" },
:path => ":rails_root/public/images/:user_id/:style/:basename.:extension",
:url => ":s3_eu_url"
process_in_background :image
end
這是工作非常快在Heroku上,但我選擇要上傳的文件,點擊按鈕上傳和幾秒鐘內就會刷新頁面。我沒有看到上傳的圖片本身,因爲尚未上傳。但後臺進程會將其上傳。 當我在2-4秒後刷新頁面時,我正確地看到上傳的圖像。
但這不是非常用戶友好的方式來做到這一點。 如何使用回形針和延遲作業將圖像快速上傳到Heroku?我錯過了什麼來正確設置它?
感謝
研究直接上傳到S3 –