证书上载有回形针和Amazon S3的照片时失踪 [英] Credentials missing when uploading photos with Paperclip and Amazon s3

查看:145
本文介绍了证书上载有回形针和Amazon S3的照片时失踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在上传照片使用回形针S3的问题。将照片下载到正确的网站,但试图上传新的提供了一个凭证丢失的消息。我试过重新我的S3键,试图更改编码访问变量,而不是它的工作。我几乎可以肯定它是照片的问题,因为如果我提交表单没有照片,它正确提交(尽管没有照片)。

I'm having issues uploading photos to S3 using Paperclip. The photos download to the site correctly, but trying to upload new ones gives a "Credentials Missing" message. I've tried resetting my S3 keys, tried to change access to the variable in the coding, not of which worked. I am almost certain it is the photo issue, because if I submit the form without the photo, it submits correctly (albeit with no photo).

下面是模型(两种车型之一,但剧本是一样的):

Here is the model (one of two models, but the script is the same):

class Outfit < ActiveRecord::Base
  attr_accessible :gender, :description, :user_id, :photo, :photo_file_name
  has_many :outfit_clothes, :dependent => :destroy
  has_many :like_relationships, :as => :liked, :dependent => :destroy
  belongs_to :user

  validates :gender,  :presence => true
  validates :photo_file_name, :presence => true
  has_attached_file :photo,
    :storage => :s3,
    :bucket => 'cold_fusion',
    :s3_credentials => {
      :access_key_id => ENV['S3_KEY'],
      :secret_access_key => ENV['S3_SECRET']
    }
end

下面是错误报告

RuntimeError在OutfitsController#创建

RuntimeError in OutfitsController#create

RuntimeError in OutfitsController#create

Missing credentials
Rails.root: /Users/calebballoch/rails_projects/product_tech

Application Trace | Framework Trace | Full Trace
rspec-core/ruby/1.9.1/gems/aws-sdk-1.3.4/lib/aws/core/default_signer.rb:47:in `initialize'
rspec-core/ruby/1.9.1/gems/aws-sdk-1.3.4/lib/aws/core/configuration.rb:371:in `new'
rspec-core/ruby/1.9.1/gems/aws-sdk-1.3.4/lib/aws/core/configuration.rb:371:in `block in <class:Configuration>'
rspec-core/ruby/1.9.1/gems/aws-sdk-1.3.4/lib/aws/core/configuration.rb:311:in `call'
rspec-core/ruby/1.9.1/gems/aws-sdk-1.3.4/lib/aws/core/configuration.rb:311:in `block in add_option_with_needs'
rspec-core/ruby/1.9.1/gems/aws-sdk-1.3.4/lib/aws/core/configuration.rb:307:in `block (2 levels) in add_option_with_needs'
rspec-core/ruby/1.9.1/gems/aws-sdk-1.3.4/lib/aws/core/configuration.rb:307:in `collect'
rspec-core/ruby/1.9.1/gems/aws-sdk-1.3.4/lib/aws/core/configuration.rb:307:in `block in add_option_with_needs'
rspec-core/ruby/1.9.1/gems/aws-sdk-1.3.4/lib/aws/core/service_interface.rb:50:in `initialize'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip/storage/s3.rb:188:in `new'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip/storage/s3.rb:188:in `s3_interface'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip/storage/s3.rb:193:in `s3_bucket'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip/storage/s3.rb:197:in `s3_object'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip/storage/s3.rb:293:in `block in flush_writes'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip/storage/s3.rb:279:in `each'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip/storage/s3.rb:279:in `flush_writes'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip/attachment.rb:214:in `save'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip.rb:468:in `block in save_attached_files'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip.rb:461:in `block in each_attachment'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip.rb:460:in `each'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip.rb:460:in `each_attachment'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip.rb:467:in `save_attached_files'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:410:in `_run_save_callbacks'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/callbacks.rb:264:in `create_or_update'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/persistence.rb:37:in `save'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/validations.rb:50:in `save'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/attribute_methods/dirty.rb:22:in `save'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/transactions.rb:241:in `block (2 levels) in save'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/transactions.rb:208:in `transaction'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/transactions.rb:241:in `block in save'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/transactions.rb:252:in `rollback_active_record_state!'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/transactions.rb:240:in `save'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/abstract_controller/base.rb:167:in `process_action'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_controller/metal/rendering.rb:10:in `process_action'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:425:in `_run__557217090004664767__process_action__2570414948427976814__callbacks'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:386:in `_run_process_action_callbacks'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/abstract_controller/callbacks.rb:17:in `process_action'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_controller/metal/rescue.rb:17:in `process_action'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/notifications.rb:53:in `block in instrument'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/notifications.rb:53:in `instrument'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_controller/metal/params_wrapper.rb:201:in `process_action'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/abstract_controller/base.rb:121:in `process'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/abstract_controller/rendering.rb:45:in `process'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_controller/metal.rb:193:in `dispatch'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_controller/metal.rb:236:in `block in action'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/routing/route_set.rb:65:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/routing/route_set.rb:65:in `dispatch'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/routing/route_set.rb:29:in `call'
rspec-core/ruby/1.9.1/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:152:in `block in call'
rspec-core/ruby/1.9.1/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:96:in `block in recognize'
rspec-core/ruby/1.9.1/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:75:in `optimized_each'
rspec-core/ruby/1.9.1/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:95:in `recognize'
rspec-core/ruby/1.9.1/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:141:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/routing/route_set.rb:532:in `call'
rspec-core/ruby/1.9.1/gems/hirefireapp-0.0.6/lib/hirefireapp/middleware.rb:27:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/etag.rb:23:in `call'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/conditionalget.rb:35:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/head.rb:14:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/flash.rb:247:in `call'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/session/abstract/id.rb:195:in `context'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/session/abstract/id.rb:190:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/cookies.rb:331:in `call'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/query_cache.rb:64:in `call'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:477:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/callbacks.rb:28:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/reloader.rb:68:in `call'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/sendfile.rb:101:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
rspec-core/ruby/1.9.1/gems/railties-3.1.3/lib/rails/rack/logger.rb:13:in `call'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/methodoverride.rb:24:in `call'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/runtime.rb:17:in `call'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/lock.rb:15:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/static.rb:53:in `call'
rspec-core/ruby/1.9.1/gems/railties-3.1.3/lib/rails/engine.rb:456:in `call'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/content_length.rb:14:in `call'
rspec-core/ruby/1.9.1/gems/railties-3.1.3/lib/rails/rack/log_tailer.rb:14:in `call'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/handler/webrick.rb:59:in `service'
/Users/calebballoch/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/Users/calebballoch/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/Users/calebballoch/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
Request

Parameters:

{"utf8"=>"✓",
 "authenticity_token"=>"loSqVZPx/d/LO2zwlG5xGaqanDJYrzKCd43zbIx19Lk=",
 "outfit"=>{"photo"=>#<ActionDispatch::Http::UploadedFile:0x0000010650f300 @original_filename="Shirley欢欢11.jpg",
 @content_type="image/jpeg",
 @headers="Content-Disposition: form-data; name=\"outfit[photo]\"; filename=\"Shirley\xE6\xAC\xA2\xE6\xAC\xA211.jpg\"\r\nContent-Type: image/jpeg\r\n",
 @tempfile=#<File:/var/folders/8f/8fdj0RXTE3SPyd7COgaQ1k+++TI/-Tmp-/RackMultipart20120223-46528-16vxkb0>>,
 "gender"=>"1",
 "description"=>"asdfas"},
 "commit"=>"Create an outfit"}
Show session dump

Show env dump

Response

Headers:

任何帮助将非常AP preciated。

Any help would be very much appreciated.

推荐答案

我在我的测试环境,为类似的问题 VersionEye 。这个问题实际上是ENV ['S3_KEY']返回一个空字符串。甚至与fakeS3这是一个问题。我花了6小时,以找出答案。

I had a similar problem in my test environment for VersionEye. The problem was actually that ENV['S3_KEY'] returned an empty string. And even with fakeS3 that was an issue. Took me 6 hours to figure that out.

这篇关于证书上载有回形针和Amazon S3的照片时失踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆