Hi :- )
I’m currently trying to write some data to an S3 bucket using the alpakka multipartUpload Sink.
It works fine until I enable Object Locking using the ‘Governance’ mode on my S3 bucket, at which point I get an ‘Invalid Request’ when I try to PUT to the bucket.
Calling code looks like this:
val result = Source.single(ByteString(key))
.runWith(S3.multipartUpload(bucket, key).withAttributes(attr))
.map(_ => ())
And I get the following response during recovery:
Upload part 1 request failed. Response header: (HttpResponse(400 Bad Request,List(x-amz-request-id: PNWB6FSGEM4QR7X3, x-amz-id-2: WjEQkBY5aOo73SdkByPuyMG27QFPAfSJWCyFSDjb00KO+rbKUd8S/FbJNl+dqWlUa8MJV7D5yis=, Date: Thu, 30 Sep 2021 11:23:26 GMT, Server: AmazonS3, Connection: close),HttpEntity.Chunked(application/xml),HttpProtocol(HTTP/1.1))), response body: (<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidRequest</Code><Message>Content-MD5 HTTP header is required for Put Part requests with Object Lock parameters</Message><RequestId>PNWB6FSGEM4QR7X3</RequestId><HostId>XXX=</HostId></Error>).
I’ve tried adding the Content-MD5 header like this:
val result = Source.single(ByteString(key))
.runWith(S3.multipartUpload(bucket, key, metaHeaders = MetaHeaders(Map("Content-MD5" -> Md5Utils.md5AsBase64(key.getBytes)))).withAttributes(attr))
.map(_ => ())
But it doesn’t change the error message.
Looking elsewhere online I don’t see others facing this issue, so maybe there’s fundamental I’m misunderstanding?
I came across this SO question where there seems to be an expectation that the Alpakka sink would be able to handle creating the Md5 hash, but I’m not sure that expectation is valid in this case.
I’m using Alpakka v. 3.0.3