2011-05-11 68 views
3

當試圖存儲文件,我得到以下幾點:S3存儲失敗,霧0.7.2 + carrierwave主分支

TypeError: can't convert nil into String 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/fog-0.7.2/lib/fog/core/hmac.rb:23:in `digest' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/fog-0.7.2/lib/fog/core/hmac.rb:23:in `block in setup_sha1' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/fog-0.7.2/lib/fog/core/hmac.rb:15:in `call' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/fog-0.7.2/lib/fog/core/hmac.rb:15:in `sign' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/fog-0.7.2/lib/fog/storage/aws.rb:309:in `signature' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/fog-0.7.2/lib/fog/storage/aws.rb:317:in `request' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/fog-0.7.2/lib/fog/storage/requests/aws/put_object.rb:43:in `put_object' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/fog-0.7.2/lib/fog/storage/models/aws/file.rb:119:in `save' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/fog-0.7.2/lib/fog/core/collection.rb:50:in `create' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/bundler/gems/carrierwave-d2cb99103a4f/lib/carrierwave/storage/fog.rb:229:in `store' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/bundler/gems/carrierwave-d2cb99103a4f/lib/carrierwave/storage/fog.rb:79:in `store!' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/bundler/gems/carrierwave-d2cb99103a4f/lib/carrierwave/uploader/store.rb:59:in `block in store!' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/bundler/gems/carrierwave-d2cb99103a4f/lib/carrierwave/uploader/callbacks.rb:17:in `with_callbacks' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/bundler/gems/carrierwave-d2cb99103a4f/lib/carrierwave/uploader/store.rb:58:in `store!' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/bundler/gems/carrierwave-d2cb99103a4f/lib/carrierwave/mount.rb:324:in `store!' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/bundler/gems/carrierwave-d2cb99103a4f/lib/carrierwave/mount.rb:214:in `store_poster!' 
... 3 levels... 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/lib/active_record/validations.rb:43:in `save' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/lib/active_record/attribute_methods/dirty.rb:21:in `save' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/lib/active_record/transactions.rb:240:in `block (2 levels) in save' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/lib/active_record/transactions.rb:292:in `block in with_transaction_returning_status' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/lib/active_record/transactions.rb:207:in `transaction' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/lib/active_record/transactions.rb:290:in `with_transaction_returning_status' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/lib/active_record/transactions.rb:240:in `block in save' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/lib/active_record/transactions.rb:251:in `rollback_active_record_state!' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/lib/active_record/transactions.rb:239:in `save' 
    from (irb):2 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands/console.rb:44:in `start' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands/console.rb:8:in `start' 
    from /Users/nick/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands.rb:23:in `<top (required)>' 
    from script/rails:6:in `require' 

我試着手動調試,我和懷疑問題是否關係中事實上@content_type被設置爲零,儘管我還沒有能夠比這更進一步推論。

這是一個S3(或霧,我沒有任何其他供應商)具體問題,我的項目使用時工作正常:文件存儲。思考?

回答

7

這個問題只是咬我一口。

S3_CONFIG = YAML.load_file(Rails.root.join('config', 'amazon_s3.yml'))[Rails.env] 

CarrierWave.configure do |config| 
    config.storage    = :s3 
    config.s3_access_policy  = :public_read 
    config.s3_access_key_id  = S3_CONFIG['access_key_id'] 
    config.s3_secret_access_key = S3_CONFIG['secret_access_key'] 
    config.s3_bucket   = S3_CONFIG['bucket'] 
end 

,並把這個在config/amazon_s3.yml

development: 
    access_key_id: xxxxxxxxxxxxxxxxxxxx 
    secret_access_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
    bucket: your-dev-bucket 

test: 
    access_key_id: xxxxxxxxxxxxxxxxxxxx 
    secret_access_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
    bucket: your-test-bucket 

production: 
    access_key_id: xxxxxxxxxxxxxxxxxxxx 
    secret_access_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
    bucket: your-prod-bucket 
+0

我在嘗試啓動服務器時遇到同樣的問題。 /Users/my-machine/.rvm/gems/ruby-1.9.3-p327/gems/carrierwave-0.7.1/lib/carrierwave/uploader/configuration.rb:73:in'eval':can not convert nil轉換爲String(TypeError)。有沒有人有關於這個問題的任何其他說明。我複製了您的帖子中的所有內容,但仍然出現錯誤。 – Chapsterj 2013-01-28 17:57:22

1

已解決。我使用的是自述文件中陳述的過時配置,而不是文檔中的新方法。

對於carrierwave的新開發人員一定要閱讀實際的RDOC,而不是自述文件。

+1

能否請您發佈錯誤的,這裏的正確的配置我將這個標籤在config/initializers/carrierwave.rb解決它?我試圖使用RDoc中的配置,但這使它變得更糟。也許我們正在研究不同的RDoc。 – 2011-05-22 16:36:07

+0

我試圖在這裏發佈我的解決方案,但評論SO是如此痛苦。我將我的評論轉到「答案」。 – nickh 2011-07-25 00:08:46

相關問題