I am in a situation where i need to set a custom header on putting an object to an s3 compatible storage system.
_, err := uploader.Upload(ctx, &s3.PutObjectInput{
Bucket: aws.String(util.GlobalConfig.S3.Bucket),
Key: aws.String(filename),
Body: w,
ContentMD5: func() *string {
h := md5.New()
h.Write(w.Bytes())
return aws.String(base64.StdEncoding.EncodeToString(h.Sum(nil)))
}(),
Metadata: metadata,
ObjectLockMode: types.ObjectLockModeCompliance,
ObjectLockRetainUntilDate: &objectLockTime,
})
How can one specify a custom header?
You can do this by registering
BuildMiddleware
to the middleware stack. Please see Customizing the AWS SDK for Go V2 Client Requests for more information.Here is a simple example: