【问题标题】:How to specify server-side S3 encryption via ActiveStorage?如何通过 ActiveStorage 指定服务器端 S3 加密?
【发布时间】:2019-12-27 17:12:59
【问题描述】:

通过回形针,我能够为 S3 指定服务器端加密,还可以像这样指定内容类型(对于不稳定的文件):

  has_attached_file :attachment,
    s3_permissions: :private,
    s3_server_side_encryption: 'AES256',
    s3_headers: lambda { |attachment|
       {
         'content-Type' => 'text/csv; charset=utf-16le'
       }
     }

在 ActiveStorage 中使用 has_attached_one 时,我会在哪里指定类似的内容?

【问题讨论】:

    标签: ruby-on-rails rails-activestorage


    【解决方案1】:

    正如您在 Active Storage 的 S3Service 中所见,上传选项从 upload 键透明地传递到 Aws::S3::Object#put 方法。 Rails 5.2 也是如此。

    所以你只需要在你的storage.yml 中指定server_side_encryption 键:

    amazon:
      service: S3
      bucket: mybucket
      * other properties *
      upload:
        server_side_encryption: "AES256"
    

    【讨论】:

      猜你喜欢
      • 2018-01-09
      • 1970-01-01
      • 1970-01-01
      • 2021-01-02
      • 1970-01-01
      • 2019-09-17
      • 1970-01-01
      • 2018-09-30
      • 1970-01-01
      相关资源
      最近更新 更多