Heroku ArgumentError(不是公认的提供者)
Heroku ArgumentError ( is not a recognized provider)
我正在尝试使用 Paperclip 和 Fog gems 将个人资料图片上传到 Google Cloud。到目前为止,这是我所拥有的
在我的 Gemfile 中
gem "paperclip", git: "git://github.com/thoughtbot/paperclip.git"
gem 'fog'
在我的用户模型中
has_attached_file :avatar,
styles: {:big => "200x200>", thumb: "50x50>"},
storage: :fog,
fog_credentials: "#{Rails.root}/config/gce.yml",
fog_directory: "google-bucket-name"
validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\Z/
当我在本地 运行 时,我可以将它上传到 google。但是,当我尝试在 Heroku 上执行此操作时,出现此错误
015-10-13T19:47:15.703642+00:00 app[web.1]: SQL (2.1ms) UPDATE "users" SET "avatar_file_name" = , "avatar_content_type" = , "avatar_file_size" = , "avatar_updated_at" = , "updated_at" = WHERE "users"."id" = [["avatar_file_name", "3.jpeg"], ["avatar_content_type", "image/jpeg"], ["avatar_file_size", 8587], ["avatar_updated_at", "2015-10-13 19:47:15.140362"], ["updated_at", "2015-10-13 19:47:15.695467"], ["id", 3]]
2015-10-13T19:47:15.707684+00:00 app[web.1]: (0.9ms) ROLLBACK
2015-10-13T19:47:15.711451+00:00 app[web.1]: F, [2015-10-13T19:47:15.711260 #3] FATAL -- :
2015-10-13T19:47:15.711457+00:00 app[web.1]: ArgumentError ( is not a recognized provider):
2015-10-13T19:47:15.711459+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/fog-core-1.32.1/lib/fog/core/services_mixin.rb:12:in `new'
2015-10-13T19:47:15.711461+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/fog-core-1.32.1/lib/fog/storage.rb:22:in `new'
2015-10-13T19:47:15.711463+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/bundler/gems/paperclip-8339e0fce5d8/lib/paperclip/storage/fog.rb:217:in `connection'
2015-10-13T19:47:15.711465+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/bundler/gems/paperclip-8339e0fce5d8/lib/paperclip/storage/fog.rb:227:in `directory'
2015-10-13T19:47:15.711468+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/bundler/gems/paperclip-8339e0fce5d8/lib/paperclip/storage/fog.rb:101:in `block in flush_writes'
2015-10-13T19:47:15.711470+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/bundler/gems/paperclip-
不确定发生了什么。
经过大量调试,我的 fog_credentials 散列在 heroku 上没有按预期进行。我没有传递 "#{Rails.root}/config/gce.yml",而是这样做。
has_attached_file :avatar,
styles: {:big => "200x200>", thumb: "50x50>"},
storage: :fog,
fog_credentials: { aws_access_key_id: '<your_access_id>'
aws_secret_access_key: '<your secret>'
provider: 'Google' },
fog_directory: "google-bucket-name"
validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\Z/
我正在尝试使用 Paperclip 和 Fog gems 将个人资料图片上传到 Google Cloud。到目前为止,这是我所拥有的
在我的 Gemfile 中
gem "paperclip", git: "git://github.com/thoughtbot/paperclip.git"
gem 'fog'
在我的用户模型中
has_attached_file :avatar,
styles: {:big => "200x200>", thumb: "50x50>"},
storage: :fog,
fog_credentials: "#{Rails.root}/config/gce.yml",
fog_directory: "google-bucket-name"
validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\Z/
当我在本地 运行 时,我可以将它上传到 google。但是,当我尝试在 Heroku 上执行此操作时,出现此错误
015-10-13T19:47:15.703642+00:00 app[web.1]: SQL (2.1ms) UPDATE "users" SET "avatar_file_name" = , "avatar_content_type" = , "avatar_file_size" = , "avatar_updated_at" = , "updated_at" = WHERE "users"."id" = [["avatar_file_name", "3.jpeg"], ["avatar_content_type", "image/jpeg"], ["avatar_file_size", 8587], ["avatar_updated_at", "2015-10-13 19:47:15.140362"], ["updated_at", "2015-10-13 19:47:15.695467"], ["id", 3]]
2015-10-13T19:47:15.707684+00:00 app[web.1]: (0.9ms) ROLLBACK
2015-10-13T19:47:15.711451+00:00 app[web.1]: F, [2015-10-13T19:47:15.711260 #3] FATAL -- :
2015-10-13T19:47:15.711457+00:00 app[web.1]: ArgumentError ( is not a recognized provider):
2015-10-13T19:47:15.711459+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/fog-core-1.32.1/lib/fog/core/services_mixin.rb:12:in `new'
2015-10-13T19:47:15.711461+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/fog-core-1.32.1/lib/fog/storage.rb:22:in `new'
2015-10-13T19:47:15.711463+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/bundler/gems/paperclip-8339e0fce5d8/lib/paperclip/storage/fog.rb:217:in `connection'
2015-10-13T19:47:15.711465+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/bundler/gems/paperclip-8339e0fce5d8/lib/paperclip/storage/fog.rb:227:in `directory'
2015-10-13T19:47:15.711468+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/bundler/gems/paperclip-8339e0fce5d8/lib/paperclip/storage/fog.rb:101:in `block in flush_writes'
2015-10-13T19:47:15.711470+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/bundler/gems/paperclip-
不确定发生了什么。
经过大量调试,我的 fog_credentials 散列在 heroku 上没有按预期进行。我没有传递 "#{Rails.root}/config/gce.yml",而是这样做。
has_attached_file :avatar,
styles: {:big => "200x200>", thumb: "50x50>"},
storage: :fog,
fog_credentials: { aws_access_key_id: '<your_access_id>'
aws_secret_access_key: '<your secret>'
provider: 'Google' },
fog_directory: "google-bucket-name"
validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\Z/