Search code examples
ruby-on-railsamazon-s3rails-activestorage

Rails ActiveStorage - Content-Type of S3 Object is empty


I use ActiveStorage for uploading object to AWS S3.
But the Content-Type of the uploaded S3 objects is empty.
How can I set content-type of them?

Following is what I did.

@brand.compiled_css.attach(io: File.open(file_path), filename: "brand.css", content_type: "text/css")

My Rails version is 5.2 and Ruby version is 2.6.2.


Solution

  • This is expected. Rails team didn’t start setting the Content-Type on the uploaded S3 object until 6.0. https://github.com/rails/rails/issues/38817