Go - 当 S3 对象名称包含“=”时出现 SignatureDoesNotMatch 错误

Go - SignatureDoesNotMatch error when S3 object name contains "="

我正在努力使用 s3manager 在 S3 上创建文件。 文件名需要采用以下格式“set=2012-04-3”,其中包含一个“=”。 没有“=”的上传完美...

代码:

sess := session.Must(session.NewSession())

uploader := s3manager.NewUploader(sess)

_, err = uploader.Upload(&s3manager.UploadInput{
    Bucket: aws.String("/testbucket/data/set=2012-04-3/"),
    Key:    aws.String("test.json"),
    Body:   bytes.NewReader([]byte(message.Body)),
})

if err != nil {
    fmt.Printf("\n Error: There was an issue uploading to s3: %s \n", err.Error())
}

如有任何帮助,将不胜感激

等号 (=) 应 URL 编码或引用为 HEX。有关详细信息,请参阅 AWS S3 文档 https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html

将post答案放在这里以防其他人需要。

sess := session.Must(session.NewSession())

uploader := s3manager.NewUploader(sess)

_, err = uploader.Upload(&s3manager.UploadInput{
    Bucket: aws.String("/testbucket"),
    Key:    aws.String("/data/set=2012-04-3/test.json"),
    Body:   bytes.NewReader([]byte(message.Body)),
})

if err != nil {
    fmt.Printf("\n Error: There was an issue uploading to s3: %s \n", err.Error())
}

Bucket 不能包含路径