Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fog(Google Cloud Storage) file store throws an TypeError (hash key "Content-Type" is not a Symbol) #2533

Closed
tamatsu opened this issue Feb 23, 2021 · 5 comments · Fixed by fog/fog-google#520
Labels

Comments

@tamatsu
Copy link

tamatsu commented Feb 23, 2021

When I tryed to upload a file to Google Cloud Storage, the following error was thrown:

TypeError (hash key "Content-Type" is not a Symbol)

version: 2.2.0

Reproduction code:

$ rails -v
Rails 6.1.3
$ rails c
> uploader = MyUploader.new
> file = Rack::Test::UploadedFile.new(File.join('plain.txt'), 'text/plain')
> uploader.store!(file)
Sending upload start command to https://storage.googleapis.com/upload/storage/v1/b/...
...
Traceback (most recent call last):
        1: from (irb):3
TypeError (hash key "Content-Type" is not a Symbol)

plain.txt

plain.txt

app/uploaders/my_uploader.rb

class MyUploader < CarrierWave::Uploader::Base
  storage :fog

  def store_dir
    "uploads"
  end
end

config/initializers/carrirewave.rb

CarrierWave.configure do |config|
  config.fog_provider = 'fog/google'
  config.fog_credentials = {
      provider:               'Google',
      google_project:         'playground-263303',
      google_json_key_location: 'cred.json'
  }
  config.fog_directory = '20210223-bucket'
end

Gemfile

gem "carrierwave", '~> 2.2.0'
gem "fog-google"
...

Gemfile.lock

...
carrierwave (2.2.0)
...
fog-google (1.12.1)
...

Thanks!

@mshibuya
Copy link
Member

Looks definitely related to #2503.
cc: @ZuevEvgenii

@mshibuya mshibuya added the bug label Feb 24, 2021
@mshibuya
Copy link
Member

#2503 and fog/fog-google#513 appears to be incompatible...
As a workaround, downgrading fog-google to 1.12.0 will help. Could you try that?

@tamatsu
Copy link
Author

tamatsu commented Feb 28, 2021

It works! The file was uploaded successfully.
Thank you for your help.

Gemfile

...
gem "carrierwave", '~> 2.2.0'
gem "fog-google", '1.12.0'
...

Gemfile.lock

...
carrierwave (2.2.0)
...
fog-google (1.12.0)
...
$ rails -v
Rails 6.1.3
$ rails c
Running via Spring preloader in process 60328
Loading development environment (Rails 6.1.3)
> uploader = MyUploader.new
> file = Rack::Test::UploadedFile.new(File.join('plain.txt'), 'text/plain')
> uploader.store!(file)
Sending upload start command to https://storage.googleapis.com/upload/storage/...
...
=> [:store_versions!]

@ryanrombough
Copy link

I also ran into this. Reverting to 1.12.0 worked. Is there any roadmap for if it will be carrierwave or fog-google that will be fixing the incompatibility? Looks like it might be Carrierwave's problem? Do you know if they are aware of the issue?

@mshibuya
Copy link
Member

The fix released in fog-google side, using fog-google >= 1.14.0 will solve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants