【发布时间】:2011-03-20 06:57:20
【问题描述】:
我正在尝试上传图片,然后在我的应用中显示它们
我在 Heroku 上配置应用程序以将文件上传到 Amazon S3。我能够将图像上传到 S3。我可以在亚马逊上看到它。但是我无法显示它。
我使用了代码:
<%= image_tag user.profile_image.avatar.url, :size => "80x80" %>
它会生成以下 HTML(我将 img 更改为 imgtag,因为 stackoverflow 不允许我添加此代码):
<imgtag alt="Bob_dylanplanetwaves" height="80" src="http://appname-heroku/uploads/profile_image/avatar/1/bob_dylanplanetwaves.jpg"; width="80" />
http://appname-heroku/uploads/profile_image/avatar/1/bob_dylanplanetwaves.jpg 不指向任何有效图像。
我尝试了以下但没有成功:
<%= image_tag user.profile_image.avatar.current_path, :size => "80x80" %>.
它生成了这个代码:
<imgtag alt="Album-the-bootleg-series-vol-4-bob-dylan-live-1966-the-royal-albert-hall-concert" height="80" src="/images/uploads/profile_image/avatar/2/album-the-bootleg-series-vol-4-bob-dylan-live-1966-the-royal-albert-hall-concert.jpg" width="80" />
在这两种情况下,图像都不会显示
我正在使用 CarrierWave 上传文件 Ruby 1.9.2、Rails 3.0.3 和 Heroku 托管
【问题讨论】:
-
您在使用 PaperClip gem 吗? (编辑 - 对不起,没看到你说 CarrierWave)
-
啊,你的代码一团糟。我清理了它,但请尝试发布它以便人们阅读它:)
标签: ruby-on-rails ruby amazon-s3 heroku carrierwave