图像似乎被添加到桶中,无法在我的应用程序上查看它

我刚刚将回形针实现到我在heroku上托管的rails应用程序中。 该应用程序似乎连接并将图像上传到s3。 以下是我在应用程序上提交表单时的一些日志示例:

2013-06-01T17:52:45.112448+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"2/vRFLrAnBnokNwohVfMhG74d3HN0/GTwype2jGJm9w=", "illustration"=>{"name"=>"Test", "illustrator"=>"Test", "image"=>#<ActionDispatch::Http::UploadedFile:0x000000050d9a58 @original_filename="DEISIGN_Cover_Illustration.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"illustration[image]\"; filename=\"DEISIGN_Cover_Illustration.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#>, "edition_id"=>"17", "tag_list"=>"Test", "description"=>"Test"}, "commit"=>"Update Illustration", "id"=>"199"} 2013-06-01T17:52:45.113280+00:00 app[web.1]: [AWS S3 200 0.424977 0 retries] head_object(:bucket_name=>"haggard",:key=>"illustrations/images/000/000/199/original/DEISIGN_Cover_Illustration.jpg") 2013-06-01T17:52:45.113496+00:00 app[web.1]: 2013-06-01T17:52:45.113496+00:00 app[web.1]: [AWS S3 200 0.085094 0 retries] head_object(:bucket_name=>"haggard",:key=>"illustrations/images/000/000/199/thumb/DEISIGN_Cover_Illustration.jpg") 2013-06-01T17:52:45.113496+00:00 app[web.1]: 2013-06-01T17:52:45.624956+00:00 app[web.1]: [AWS S3 204 0.099689 0 retries] delete_object(:bucket_name=>"haggard",:key=>"illustrations/images/000/000/199/original/DEISIGN_Cover_Illustration.jpg") 2013-06-01T17:52:45.624956+00:00 app[web.1]: 2013-06-01T17:52:45.715606+00:00 app[web.1]: [AWS S3 204 0.09001 0 retries] delete_object(:bucket_name=>"haggard",:key=>"illustrations/images/000/000/199/thumb/DEISIGN_Cover_Illustration.jpg") 2013-06-01T17:52:45.715606+00:00 app[web.1]: 2013-06-01T17:52:46.835310+00:00 app[web.1]: [AWS S3 200 1.116787 0 retries] put_object(:acl=>:public_read,:bucket_name=>"haggard",:content_length=>575121,:content_type=>"image/jpeg",:data=>Paperclip::UploadedFileAdapter: DEISIGN_Cover_Illustration.jpg,:key=>"illustrations/images/000/000/199/original/DEISIGN_Cover_Illustration.jpg") 2013-06-01T17:52:46.835310+00:00 app[web.1]: 2013-06-01T17:52:47.011793+00:00 app[web.1]: [AWS S3 200 0.173532 0 retries] put_object(:acl=>:public_read,:bucket_name=>"haggard",:content_length=>6096,:content_type=>"image/jpeg",:data=>Paperclip::FileAdapter: DEISIGN_Cover_Illustration20130601-12-6ldegn20130601-12-1ytcjd0,:key=>"illustrations/images/000/000/199/thumb/DEISIGN_Cover_Illustration.jpg") 2013-06-01T17:52:47.011793+00:00 app[web.1]: 2013-06-01T17:52:47.020929+00:00 app[web.1]: Redirected to http://visualhaggard.org/illustrations/199 

我上传的图片显示在我的S3存储分区控制台中。

我的视图使用@illustration.image.url来显示图像。

我没有为图像设置任何权限。 它们是否自动设置为应用程序上传和下载图像?

谢谢。

首先,您必须在s3存储桶中将所有图像设置为公共图像。 如果默认情况下将图像设置为私有。 如果图像是私密的,您将无法看到图像。

其次,设置s3存储桶的所有凭据。

在** config / s3.yml文件中设置s3凭证为

 development: access_key_id: your_access_key_id secret_access_key: your_access_key bucket: your_bucket_name production: access_key_id: your_access_key_id secret_access_key: your_access_key bucket: your_bucket_name 

然后在config / initializers / s3.rb文件中将所有图像初始化为

 if Rails.env == "production" # set credentials from ENV hash S3_CREDENTIALS = { :access_key_id => ENV['access_key_id'], :secret_access_key => ENV['secret_key'], :bucket => "bucket_name"} else # get credentials from YML file S3_CREDENTIALS = Rails.root.join("config/s3.yml") end