我在 application.rb 中设置了 ENV 变量
ENV['S3_KEY']='key'
ENV['S3_SECRET']='secret'
ENV['S3_BUCKET']='myapp-development'
我已将“雾”宝石添加到我的 Gemfile
gem 'fog'
我已将此添加到 development.rb 的最后
Refinery::Core.config.s3_backend = true
而且,通过实验,我还将我的 S3 密钥和秘密添加到我的 bash_profile 中:
export S3_KEY=key
export S3_SECRET=secret
无论如何,当我上传文件时,它们不会进入我的 S3 存储桶,而是(我假设)存储在本地。这是上传文件的日志操作:
Started POST "/refinery/images?dialog=true" for 127.0.0.1 at 2012-04-27 19:07:46 -0400
Processing by Refinery::Admin::ImagesController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"bofz2fukPA6e/olwZ2zXlkdj/apaxZ69aZnh6xSGkT4=", "image"=>{"image"=>[#<ActionDispatch::Http::UploadedFile:0x007f9d54045c60 @original_filename="4.jpeg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"image[image][]\"; filename=\"4.jpeg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/var/folders/zv/h2w4bghn3gj_5t9ws6x7s6r40000gn/T/RackMultipart20120427-36682-ptku7o>>]}, "wymeditor"=>"", "modal"=>"true", "dialog"=>"true", "app_dialog"=>"true", "field"=>"", "update_image"=>"", "thumbnail"=>"", "callback"=>"", "conditions"=>"", "locale"=>:en}
Refinery::Role Load (0.6ms) SELECT "refinery_roles".* FROM "refinery_roles" WHERE "refinery_roles"."title" = 'Refinery' LIMIT 1
Refinery::User Load (0.7ms) SELECT "refinery_users".* FROM "refinery_users" INNER JOIN "refinery_roles_users" ON "refinery_users"."id" = "refinery_roles_users"."user_id" WHERE "refinery_roles_users"."role_id" = 1
Refinery::User Load (0.4ms) SELECT "refinery_users".* FROM "refinery_users" WHERE "refinery_users"."id" = 1 LIMIT 1
Refinery::UserPlugin Load (0.3ms) SELECT "refinery_user_plugins".* FROM "refinery_user_plugins" WHERE "refinery_user_plugins"."user_id" = 1 ORDER BY position ASC
Refinery::Role Load (0.8ms) SELECT "refinery_roles".* FROM "refinery_roles" INNER JOIN "refinery_roles_users" ON "refinery_roles"."id" = "refinery_roles_users"."role_id" WHERE "refinery_roles_users"."user_id" = 1
(0.2ms) BEGIN
SQL (3.1ms) INSERT INTO "refinery_images" ("created_at", "image_ext", "image_height", "image_mime_type", "image_name", "image_size", "image_uid", "image_width", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING "id" [["created_at", Fri, 27 Apr 2012 23:07:47 UTC +00:00], ["image_ext", nil], ["image_height", 320], ["image_mime_type", "image/jpeg"], ["image_name", "4.jpeg"], ["image_size", 46220], ["image_uid", "2012/04/27/19/07/47/673/4.jpeg"], ["image_width", 480], ["updated_at", Fri, 27 Apr 2012 23:07:47 UTC +00:00]]
(0.6ms) COMMIT
Rendered text template within layouts/refinery/admin_dialog (0.0ms)
Rendered refinery/_html_tag.html.erb (0.3ms)
Rendered /Users/anonymouscoward/.rvm/gems/ruby-1.9.3-p125@refinerycms/gems/refinerycms-core-2.0.3/app/views/refinery/admin/_dialog_success.html.erb (0.6ms)
Completed 200 OK in 1127ms (Views: 99.4ms | ActiveRecord: 6.7ms)
cache: [GET /refinery/images/new?app_dialog=true&dialog=true] miss
cache: [GET /refinery/images/new?app_dialog=true&dialog=true] miss
Started GET "/refinery/images/new?app_dialog=true&dialog=true" for 127.0.0.1 at 2012-04-27 19:07:47 -0400
Processing by Refinery::Admin::ImagesController#new as HTML
Parameters: {"app_dialog"=>"true", "dialog"=>"true", "locale"=>:en}
Refinery::Role Load (0.5ms) SELECT "refinery_roles".* FROM "refinery_roles" WHERE "refinery_roles"."title" = 'Refinery' LIMIT 1
Refinery::User Load (0.7ms) SELECT "refinery_users".* FROM "refinery_users" INNER JOIN "refinery_roles_users" ON "refinery_users"."id" = "refinery_roles_users"."user_id" WHERE "refinery_roles_users"."role_id" = 1
Refinery::User Load (0.6ms) SELECT "refinery_users".* FROM "refinery_users" WHERE "refinery_users"."id" = 1 LIMIT 1
Refinery::UserPlugin Load (0.5ms) SELECT "refinery_user_plugins".* FROM "refinery_user_plugins" WHERE "refinery_user_plugins"."user_id" = 1 ORDER BY position ASC
Refinery::Role Load (0.6ms) SELECT "refinery_roles".* FROM "refinery_roles" INNER JOIN "refinery_roles_users" ON "refinery_roles"."id" = "refinery_roles_users"."role_id" WHERE "refinery_roles_users"."user_id" = 1
Rendered /Users/anonymouscoward/.rvm/gems/ruby-1.9.3-p125@refinerycms/gems/refinerycms-core-2.0.3/app/views/refinery/admin/_error_messages.html.erb (0.1ms)
Rendered /Users/anonymouscoward/.rvm/gems/ruby-1.9.3-p125@refinerycms/gems/refinerycms-core-2.0.3/app/views/refinery/admin/_form_actions.html.erb (1.0ms)
Rendered /Users/anonymouscoward/.rvm/gems/ruby-1.9.3-p125@refinerycms/gems/refinerycms-images-2.0.3/app/views/refinery/admin/images/_form.html.erb (13.9ms)
Rendered /Users/anonymouscoward/.rvm/gems/ruby-1.9.3-p125@refinerycms/gems/refinerycms-images-2.0.3/app/views/refinery/admin/images/new.html.erb within layouts/refinery/admin_dialog (16.9ms)
Rendered refinery/_html_tag.html.erb (0.2ms)
Rendered /Users/anonymouscoward/.rvm/gems/ruby-1.9.3-p125@refinerycms/gems/refinerycms-core-2.0.3/app/views/refinery/admin/_javascripts.html.erb (3.0ms)
Rendered /Users/anonymouscoward/.rvm/gems/ruby-1.9.3-p125@refinerycms/gems/refinerycms-core-2.0.3/app/views/refinery/admin/_head.html.erb (9.9ms)
Rendered refinery/_message.html.erb (0.6ms)
Completed 200 OK in 64ms (Views: 49.0ms | ActiveRecord: 2.9ms)
[2012-04-27 19:07:47] ERROR Errno::ECONNRESET: Connection reset by peer
/Users/anonymouscoward/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/httpserver.rb:80:in `eof?'
/Users/anonymouscoward/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/httpserver.rb:80:in `run'
/Users/anonymouscoward/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
cache: [GET /refinery/images?_=1335568067618] miss
cache: [GET /refinery/images?_=1335568067618] miss
Started GET "/refinery/images?_=1335568067618" for 127.0.0.1 at 2012-04-27 19:07:47 -0400
Processing by Refinery::Admin::ImagesController#index as */*
Parameters: {"_"=>"1335568067618", "locale"=>:en}
Refinery::Role Load (1.4ms) SELECT "refinery_roles".* FROM "refinery_roles" WHERE "refinery_roles"."title" = 'Refinery' LIMIT 1
Refinery::User Load (3.0ms) SELECT "refinery_users".* FROM "refinery_users" INNER JOIN "refinery_roles_users" ON "refinery_users"."id" = "refinery_roles_users"."user_id" WHERE "refinery_roles_users"."role_id" = 1
Refinery::User Load (0.9ms) SELECT "refinery_users".* FROM "refinery_users" WHERE "refinery_users"."id" = 1 LIMIT 1
Refinery::UserPlugin Load (0.5ms) SELECT "refinery_user_plugins".* FROM "refinery_user_plugins" WHERE "refinery_user_plugins"."user_id" = 1 ORDER BY position ASC
Refinery::Role Load (0.6ms) SELECT "refinery_roles".* FROM "refinery_roles" INNER JOIN "refinery_roles_users" ON "refinery_roles"."id" = "refinery_roles_users"."role_id" WHERE "refinery_roles_users"."user_id" = 1
(0.5ms) SELECT COUNT(*) FROM "refinery_images"
Refinery::Image Load (0.5ms) SELECT "refinery_images".* FROM "refinery_images" ORDER BY created_at DESC LIMIT 20 OFFSET 0
Rendered /Users/anonymouscoward/.rvm/gems/ruby-1.9.3-p125@refinerycms/gems/refinerycms-images-2.0.3/app/views/refinery/admin/images/_grid_view.html.erb (11.3ms)
Rendered /Users/anonymouscoward/.rvm/gems/ruby-1.9.3-p125@refinerycms/gems/refinerycms-images-2.0.3/app/views/refinery/admin/images/_images.html.erb (40.6ms)
Rendered text template within layouts/refinery/flash (0.0ms)
Rendered refinery/_message.html.erb (1.6ms)
Completed 200 OK in 96ms (Views: 11.3ms | ActiveRecord: 7.6ms)
cache: [GET /system/images/BAhbB1sHOgZmSSIjMjAxMi8wNC8yNy8xOS8wNy80Ny82NzMvNC5qcGVnBjoGRVRbCDoGcDoKdGh1bWJJIg4xMzV4MTM1I2MGOwZU/4.jpeg] miss, store
cache: [GET /system/images/BAhbB1sHOgZmSSIjMjAxMi8wNC8yNy8xOS8wNy80Ny82NzMvNC5qcGVnBjoGRVRbCDoGcDoKdGh1bWJJIg4xMzV4MTM1I2MGOwZU/4.jpeg] miss, store
Started GET "/system/images/BAhbB1sHOgZmSSIjMjAxMi8wNC8yNy8xOS8wNy80Ny82NzMvNC5qcGVnBjoGRVRbCDoGcDoKdGh1bWJJIg4xMzV4MTM1I2MGOwZU/4.jpeg" for 127.0.0.1 at 2012-04-27 19:07:47 -0400
cache: [GET /assets/refinery/icons/application_edit.png] stale, valid, store
cache: [GET /assets/refinery/icons/application_edit.png] stale, valid, store
Started GET "/assets/refinery/icons/application_edit.png" for 127.0.0.1 at 2012-04-27 19:07:48 -0400
Served asset /refinery/icons/application_edit.png - 304 Not Modified (10ms)
[2012-04-27 19:07:48] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
cache: [GET /assets/refinery/icons/accept.png] stale, valid, store
cache: [GET /assets/refinery/icons/accept.png] stale, valid, store
Started GET "/assets/refinery/icons/accept.png" for 127.0.0.1 at 2012-04-27 19:07:48 -0400
Served asset /refinery/icons/accept.png - 304 Not Modified (8ms)
[2012-04-27 19:07:48] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
cache: [GET /assets/refinery/icons/eye.png] stale, valid, store
cache: [GET /assets/refinery/icons/eye.png] stale, valid, store
Started GET "/assets/refinery/icons/eye.png" for 127.0.0.1 at 2012-04-27 19:07:48 -0400
Served asset /refinery/icons/eye.png - 304 Not Modified (8ms)
[2012-04-27 19:07:48] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
cache: [GET /assets/refinery/icons/delete.png] stale, valid, store
cache: [GET /assets/refinery/icons/delete.png] stale, valid, store
Started GET "/assets/refinery/icons/delete.png" for 127.0.0.1 at 2012-04-27 19:07:48 -0400
Served asset /refinery/icons/delete.png - 304 Not Modified (5ms)
[2012-04-27 19:07:48] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true