在解決我的項目中的圖片問題時遇到問題。Rails 4,Heroku上的回形針不能識別破碎的圖像
總結:Rilas 4託管在Heroku使用Paerclip與S3
問題開始與具有使用以前使用的自定義上傳邏輯與S3。圖片網址看起來像這樣/profile_picture/:style_:image_hash
。它適用於那裏的圖像,但圖像不存在的回形針仍然試圖訪問不存在的圖像,實際的鏈接看起來像這樣:http://s3.amazonaws.com/project/profile_pictures/100h_
。
has_attached_file :picture,
styles: { :'53h' => '', :'100h' => '' },
convert_options: {
:'100h' => '-gravity center -thumbnail 165x165^ -extent 165x165',
:'53h' => '-gravity center -thumbnail 45x45^ -extent 45x45'
},
path: 'profile_pictures/:style_:filename',
default_url: '/images/default-pp-large.jpg'
我猜測,可能是因爲實際文件名中的風格,但我不知道,eather方式defauly_url
不能正常工作和圖像全部被破壞,不包括實際上存在的人。
你能幫忙嗎?
我不能這樣做,因爲,就像我說的,遷移與現有的S3文件來了,所以改變實際路徑文件是不是一種選擇。 – user2945241