func()

in dth/client.go [359:400]


func (c *S3Client) PutObject(ctx context.Context, key *string, body []byte, storageClass, acl *string, meta *Metadata) (etag *string, err error) {
	// log.Printf("S3> Uploading object %s to bucket %s\n", key, c.bucket)

	md5Bytes := md5.Sum(body)
	// contentMD5 := hex.EncodeToString(md5Bytes[:])
	contentMD5 := base64.StdEncoding.EncodeToString(md5Bytes[:])
	// fmt.Println(contentMD5)
	reader := bytes.NewReader(body)

	if *acl == "" {
		*acl = string(types.ObjectCannedACLBucketOwnerFullControl)
	}

	input := &s3.PutObjectInput{
		Bucket:       &c.bucket,
		Key:          key,
		Body:         reader,
		ContentMD5:   &contentMD5,
		StorageClass: types.StorageClass(*storageClass),
		ACL:          types.ObjectCannedACL(*acl),
	}
	if meta != nil {
		input.ContentType = meta.ContentType
		input.ContentEncoding = meta.ContentEncoding
		input.ContentLanguage = meta.ContentLanguage
		input.CacheControl = meta.CacheControl
		input.Metadata = meta.Metadata
	}

	output, err := c.client.PutObject(ctx, input)
	if err != nil {
		log.Printf("S3> Got an error uploading file - %s\n", err.Error())
		// return nil, err
	} else {
		_etag := strings.Trim(*output.ETag, "\"")
		etag = &_etag
		// fmt.Println(output.ETag)
	}

	return

}