【问题标题】:nodejs client s3 getSignedUrl gives Requests specifying Server Side Encryption with AWS KMS managed keys require AWS Signature Version 4nodejs 客户端 s3 getSignedUrl 提供使用 AWS KMS 托管密钥指定服务器端加密的请求需要 AWS 签名版本 4
【发布时间】:2020-07-12 07:23:58
【问题描述】:

我正在使用以下代码生成到 s3 存储桶的预签名 URL

  const presignedUrl = s3.getSignedUrl('getObject', {
    Bucket: config.parsedResumeDestination,
    Key: tmpKey,
    Expires: 60 * 60 * 60 // 1 hour
  });

但是,当我在浏览器上复制生成的 url 时,会出现以下错误

Requests specifying Server Side Encryption with AWS KMS managed keys require AWS Signature Version 4

我看到了下面的解决方案How to generate AWS S3 pre-signed URL using signature version 4,但是aws的nodejs客户端似乎没有这个属性。谁能告诉我这里出了什么问题?

【问题讨论】:

    标签: node.js amazon-s3


    【解决方案1】:

    在构造 s3 服务对象时,传入一个signatureVersion

    这是一种方法:

    const AWS = require("aws-sdk");
    const s3 = new AWS.S3({
      signatureVersion: "v4",
      ...credentials
    })
    

    在构建 AWS 服务对象时有很多选项,它们大多是通用的: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property

    【讨论】:

      猜你喜欢
      • 2022-10-23
      • 2022-11-08
      • 2021-02-02
      • 2017-09-14
      • 2022-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-06
      相关资源
      最近更新 更多