我參考這個應用程序link作爲教程。看完之後。我很想了解程序(客戶端或服務器)如何訪問圖像。由於該程序在上載到Amazon S3後似乎沒有明確地將圖像URL保存在服務器的數據庫中?回形針和aws寶石 - 照片共享應用程序哪裏存儲的回形針/ aws?
實施此應用程序後,我沒有看到image_urls或數據庫中的路徑列。但該程序神奇地加載客戶端中的圖像!
引擎蓋下正在發生什麼,這是什麼東西?
這裏是照片模型的方法:
Paperclip.interpolates :prefix do |attachment, style|
"#{attachment.instance.takenby}/#{Date.today.to_s }/#
{attachment.instance.image_file_name}"
end
has_attached_file :image,
:path => ":prefix/:style/:basename.:extension",
:styles => { :thumbnail => "57x57", :original => "300x300" },
:storage => :s3,
:s3_credentials => S3_CREDENTIALS
validates :image,:presence => true
validates :lat, :lng,:presence => true,:numericality => true
你打在頭上的指甲。 :前綴是exatcly是什麼導致重建路徑的問題!超過1天的圖像無法檢索。我已經提前並改變了它。我對它是如何工作感到困惑,但現在這一切都有道理。非常感謝你澄清。爲此 – banditKing