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

ArgumentError (unknown keyword: content_type) #34551

Closed
carlqt opened this issue Nov 28, 2018 · 2 comments
Closed

ArgumentError (unknown keyword: content_type) #34551

carlqt opened this issue Nov 28, 2018 · 2 comments

Comments

@carlqt
Copy link

carlqt commented Nov 28, 2018

Steps to reproduce

  1. Create a new rails project
  2. configure active_storage then update storage.yml with credentials on your s3 bucket.
  3. configure development.rb to use :amazon as its active_storage.service`
  4. generate a simple scaffold and have the model use active_storage
  5. update views form to be able to upload an image/file
  6. try and upload a simple image.

Expected behavior

File should be uploaded successfully and can be found in your s3 bucket

Actual behavior

Getting an error

ArgumentError (unknown keyword: content_type):

app/controllers/profiles_controller.rb:27:in `create'`

System configuration

Rails version: 5.2.1.1

Ruby version: 2.5.0

Findings

ActiveStorage::Blob#upload in app/models/active_storage/blob.rb is calling service.upload key, io, checksum: checksum, **service_metadata.

The method signature of the #upload method of service doesn't include content_type, but the service_metadata method is returning a hash with content_type as key.

@zealot128
Copy link
Contributor

Same thing here. We are using AWS, too, and after upgrading to 5.2.1.1 uploads fail currently.

model.logo.attach(io: file, filename: 'theme.css')

unknown keywords: content_type, disposition, filename
activestorage-5.2.1.1/lib/active_storage/service/s3_service.rb:19→ upload
activestorage-5.2.1.1/app/models/active_storage/blob.rb:155→ upload
activestorage-5.2.1.1/app/models/active_storage/blob.rb:53→ block in build_after_upload
activestorage-5.2.1.1/app/models/active_storage/blob.rb:48→ tap
activestorage-5.2.1.1/app/models/active_storage/blob.rb:48→ build_after_upload
activestorage-5.2.1.1/app/models/active_storage/blob.rb:61→ create_after_upload!
activestorage-5.2.1.1/lib/active_storage/attached.rb:28→ create_blob_from
activestorage-5.2.1.1/lib/active_storage/attached/one.rb:24→ attach

This was not spotted by our tests, as local file adapter works....

@zealot128
Copy link
Contributor

There is already a PR: #34550

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

No branches or pull requests

4 participants