I am trying to set the Content-MD5 header when I use Minio Golang SDK to upload a file to S3. I can successfully upload files to AWS without setting Content-MD5, but uploading to IBM Cloud Object Storage fails with the following error:
ERR: Object write failed, reason: Missing required header for this request: Content-MD5
According to the Minio SDK,
https://docs.minio.io/docs/golang-client-api-reference#FPutObject
I use the UserMetadata field in minio.PutObjectOptions to set Content-MD5, but IBM Cloud Object Storage keeps complaining missing MD5, am I doing something wrong in the following code?
func (cloudIO *CloudIO) FWrite(name string) (n int, err error) {
f, err := os.Open(name)
if err != nil {
log.Fatal(err)
}
defer f.Close()
h := md5.New()
if _, err := io.Copy(h, f); err != nil {
log.Fatal(err)
}
bytesWritten, err := cloudIO.client.FPutObject(cloudIO.bucket, cloudIO.address,
name,
minio.PutObjectOptions{UserMetadata: map[string]string{"Content-MD5": hex.EncodeToString(h.Sum(nil))}})
return int(bytesWritten), err
}