【问题标题】:Rails ActiveStorage - Content-Type of S3 Object is emptyRails ActiveStorage - S3 对象的 Content-Type 为空
【发布时间】:2020-07-06 17:53:17
【问题描述】:

我使用 ActiveStorage 将对象上传到 AWS S3。
但是上传的 S3 对象的 Content-Type 是空的。
如何设置它们的内容类型?

以下是我所做的。

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

我的 Rails 版本是 5.2,Ruby 版本是 2.6.2。

【问题讨论】:

    标签: ruby-on-rails amazon-s3 rails-activestorage


    【解决方案1】:

    这是意料之中的。 Rails 团队直到 6.0 才开始在上传的 S3 对象上设置 Content-Type。 https://github.com/rails/rails/issues/38817

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-16
      • 1970-01-01
      • 2023-04-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多