2

这个 AWS 安全问题让我抓狂。我正在尝试使用knox从节点应用程序上传一些二进制文件。我的密钥/秘密组合不断收到臭名昭著的SignatureDoesNotMatch错误。我将其追溯到这个:使用例如 Transmit,我可以通过连接来访问存储桶s3.amazonaws.com,但我无法通过虚拟子域访问它mybucket.s3.amazonaws.com。(当我尝试使用 s3.amazonaws.com/mybucket 语法访问存储桶时,我收到一条错误消息,指出只允许使用子域样式。)

我已尝试将存储桶策略设置为明确允许PUT相应用户使用,但这没有效果。谁能解释一下我如何能够从一个特定的 AWS 用户上传文件?

4

1 回答 1

0

经过大量的试验和错误,我将其缩小到几个问题。我不完全确定哪一个最终修复了它,但这里有一些你可能想尝试的事情:

  • 确保您设置了正确的数据中心。就我而言,这看起来像这样:

    knox.createClient({
           key: this.config.key
      , secret: this.config.secret
      , bucket: this.config.bucket
      , region: 'us-west-2' // cause my bucket is supposed to be in oregon
    });
    
  • 检查您的 PUT 标头。在我的情况下,Content-Type被意外设置为undef导致问题:

    var headers = {
        'x-amz-acl': 'public-read' // if you want anyone to be able to download the file
    };
    if (filesize) headers['Content-Length'] = filesize;
    if (mime) headers['Content-Type'] = mime;
    
于 2013-08-30T10:08:57.730 回答