适用于AWS S3的Content-MD5签名的UploadPart标题

时间:2019-02-07 04:56:01

标签: swift amazon-web-services amazon-s3 alamofire

使用AWS MultipartUpload上传零件时,如果添加md5标头,它将失败。谁能告诉我我是否正确计算了校验和?

现在我只是使用CryptoSwift并以此方式抓取

data.md5().base64EncodedString()

我上传的数据是

Alamofire.upload(
  data, 
  to: presignedMultipartLink, 
  method: Alamofire.HTTPMethod.put, 
  headers: [
    "Content-Length": sizeOfPart, 
    "Content-MD5": data.md5().base64EncodedString()
  ])
  .uploadProgress{...}
  .response{...}

如果我取出Content-MD5标头,它就会按需工作。

xml响应是,那么如何添加md5标头?

<Error><Code>AccessDenied</Code><Message>There were headers present in the request which were not signed</Message><HeadersNotSigned>content-md5</HeadersNotSigned><RequestId>requestid</RequestId><HostId>hostid</HostId></Error>

1 个答案:

答案 0 :(得分:0)

我需要在getPresignedUrl调用中包含一个参数。否则不能包含在内。 ah ...那些日子之一。