3

我一直在寻找类似主题的解决方案,但我无法让它以某种方式工作。这是我的应用程序日志

Command :: identify -format %wx%h '/tmp/0120121215-31657-19vihny.jpg[0]'
Command :: convert '/tmp/0120121215-31657-19vihny.jpg[0]' -auto-orient -resize "32x32!" -     background white -flatten +matte '/tmp/0120121215-31657-19vihny20121215-31657-58mm3a.png'
Command :: identify -format %wx%h '/tmp/0120121215-31657-19vihny.jpg[0]'
Command :: convert '/tmp/0120121215-31657-19vihny.jpg[0]' -auto-orient -resize "320x320!" -background white -flatten +matte '/tmp/0120121215-31657-19vihny20121215-31657-1n3fgl2.png'

[paperclip] Saving attachments.
[paperclip] saving images/:User/50cc0cfb0feea807f6000004/original.jpg
[paperclip] saving images/:User/50cc0cfb0feea807f6000004/small.png
[paperclip] saving images/:User/50cc0cfb0feea807f6000004/medium.png

Started POST "/photos" for 127.0.0.1 at 2012-12-15 12:39:07 +0700
Processing by PhotosController#create as HTML 
Parameters: {"utf8"=>"✓", "authenticity_token"=>"SSjceuOzRNQfJyUCki86mNBfuHsK0bh5qQmX4pBi7uk=", "photo"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0xb27e0164 @original_filename="01.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"photo[image]\"; filename=\"01.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/tmp/RackMultipart20121215-31657-9oqjbm>>, "description"=>"This is decscription"}, "commit"=>"Create Photo"}

MOPED: 127.0.0.1:27017 COMMAND      database=admin command={:ismaster=>1} (0.7489ms)
MOPED: 127.0.0.1:27017 INSERT       database=image12345_development collection=photos documents=[{"_id"=>"50cc0cfb0feea807f6000004", "image_file_name"=>"01.jpg", "image_content_type"=>"image/jpeg", "image_file_size"=>368812, "image_updated_at"=>2012-12-15 05:39:07 UTC, "description"=>"This is decscription"}] flags=[] (0.2658ms)

[AWS S3 200 8.971826 0 retries] put_object(:acl=>:public_read,:bucket_name=>"image12345",:content_length=>368812,:content_type=>"image/jpeg",:data=>Paperclip::UploadedFileAdapter: 01.jpg,:key=>"images/:User/50cc0cfb0feea807f6000004/original.jpg")  

[AWS S3 200 0.214209 0 retries] put_object(:acl=>:public_read,:bucket_name=>"image12345",:content_length=>2763,:content_type=>"image/png",:data=>Paperclip::FileAdapter: 0120121215-31657-19vihny20121215-31657-58mm3a.png,:key=>"images/:User/50cc0cfb0feea807f6000004/small.png")  

[AWS S3 200 3.498196 0 retries] put_object(:acl=>:public_read,:bucket_name=>"image12345",:content_length=>142791,:content_type=>"image/png",:data=>Paperclip::FileAdapter: 0120121215-31657-19vihny20121215-31657-1n3fgl2.png,:key=>"images/:User/50cc0cfb0feea807f6000004/medium.png")  

Redirected to http://localhost:3000/photos/50cc0cfb0feea807f6000004
Completed 302 Found in 12992ms

我为用户使用设计

在我的 gem 文件中有

gem "mongoid-paperclip", :require => "mongoid_paperclip"
gem 'paperclip'
gem "aws-sdk"

在我的模型/photo.rb

has_mongoid_attached_file :image,
:path           => ':attachment/:User/:id/:style.:extension',
:storage        => :s3,
:s3_credentials => File.join(Rails.root, 'config', 's3.yml'), #s3.yml contain credentials
:styles => {
:small => ['32x32!', :png],
:medium   => ['320x320!',    :png, :jpg],

},
:convert_options => { :all => '-background white -flatten +matte' }  
attr_accessible :image, :description

以我的形式

<%= form_for(@photo , :html => {:multipart => true} ) do |f| %>
<div class="field">
    <%= f.label :image %><br />
    <%= f.file_field :image %>
</div>
<% end %>

我已经尝试了许多解决方案,例如 add form_helper :multipart ,在我以前的应用程序中,这个模型和 gem 运行良好,我确信凭证是正确的。它只是告诉我这是一个成功的更新,但没有上传图像。我在哪里可以查找有关此问题的错误?或者我可以使用的任何工具?我真的坚持这一点并想通过它,而不是创建新的应用程序并祝好运。

4

1 回答 1

0

前段时间已经找到解决方案但忘记发布

在这个问题 Rails 3 - Amazon S3 Paperclip EU Problem

当我看到一张图片已经上传时才知道,但只是我没有使用正确的地址来访问它们:)

于 2013-01-05T08:24:22.987 回答