2017-02-26 82 views
0

我試圖用paperclip和aws sdk將圖片上傳到s3。我得到這個錯誤,是否有任何煽動你可以給我解決錯誤。是計劃與在production.rb文件註釋掉的代碼s3不能用回形針,錯誤

2017-02-26T12:05:12.109005+00:00 app[web.1]: SQL (2.6ms) INSERT INTO "pics" ("title", "description", "image_file_name", "image_content_type", "image_file_size", "image_updated_at", "user_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING "id" [["title", "shthth"], ["description", "sthshst"], ["image_file_name", "cartoon_napp_bald.png"], ["image_content_type", "image/png"], ["image_file_size", 152774], ["image_updated_at", "2017-02-26 12:05:11.878778"], ["user_id", 1], ["created_at", "2017-02-26 12:05:12.099885"], ["updated_at", "2017-02-26 12:05:12.099885"]] 
    2017-02-26T12:05:12.109901+00:00 app[web.1]: [paperclip] saving /pics/images/000/000/010/original/cartoon_napp_bald.png 
    2017-02-26T12:05:12.116125+00:00 app[web.1]: (2.3ms) ROLLBACK 
    2017-02-26T12:05:12.116666+00:00 app[web.1]: Completed 500 Internal Server Error in 245ms (ActiveRecord: 7.9ms) 
    2017-02-26T12:05:12.117484+00:00 app[web.1]: 
    2017-02-26T12:05:12.117486+00:00 app[web.1]: NameError (uninitialized constant Paperclip::Storage::S3::AWS): 
    2017-02-26T12:05:12.117487+00:00 app[web.1]: app/controllers/pics_controller.rb:19:in `create' 
    2017-02-26T12:05:12.117488+00:00 app[web.1]: 
    2017-02-26T12:05:12.117489+00:00 app[web.1]: 
    2017-02-26T12:05:12.129680+00:00 heroku[router]: at=info method=POST path="/pics" host=justshare.herokuapp.com request_id=048573a9-bea0-46c1-b91f-453fa091d0f3 fwd="98.213.220.117" dyno=web.1 connect=1ms service=397ms status=500 bytes=1754 

回答

0

我現在明白了它在其他職位

的Gemfile

gem 'paperclip', :git=> 'https://github.com/thoughtbot/paperclip', :ref => '523bd46c768226893f23889079a7aa9c73b57d68' 
    gem 'aws-sdk', '< 2.0' 

production.rb

不超清晰
config.active_record.dump_schema_after_migration = false 

    config.paperclip_defaults = { 
    storage: :s3, 
    s3_credentials: { 
    bucket: ENV.fetch('S3_BUCKET_NAME'), 
    access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'), 
    secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'), 
    s3_region: ENV.fetch('AWS_REGION'), 
    } 
} 

in terminal

heroku config:set AWS_REGION=us-east-1