summaryrefslogtreecommitdiff
path: root/vendor/github.com/minio/minio-go/v7/api-put-object-streaming.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2024-09-26 12:43:10 +0000
committerLibravatar GitHub <noreply@github.com>2024-09-26 14:43:10 +0200
commit53ee6aef0885b4055ef95bf4f20ee78fd381e333 (patch)
treea181b038dc969482b34690603328dd6b756a42fb /vendor/github.com/minio/minio-go/v7/api-put-object-streaming.go
parent[chore] reduce number admin process workers (#3354) (diff)
downloadgotosocial-53ee6aef0885b4055ef95bf4f20ee78fd381e333.tar.xz
[bugfix] s3 media uploaded without content-type (#3353)
* update go-storage dependency, for S3Storage manually call PutObject() so we can set content-type * update calls to PutFile() to include the contentType
Diffstat (limited to 'vendor/github.com/minio/minio-go/v7/api-put-object-streaming.go')
-rw-r--r--vendor/github.com/minio/minio-go/v7/api-put-object-streaming.go49
1 files changed, 32 insertions, 17 deletions
diff --git a/vendor/github.com/minio/minio-go/v7/api-put-object-streaming.go b/vendor/github.com/minio/minio-go/v7/api-put-object-streaming.go
index 7f316564b..eef976c8c 100644
--- a/vendor/github.com/minio/minio-go/v7/api-put-object-streaming.go
+++ b/vendor/github.com/minio/minio-go/v7/api-put-object-streaming.go
@@ -108,7 +108,9 @@ func (c *Client) putObjectMultipartStreamFromReadAt(ctx context.Context, bucketN
if err != nil {
return UploadInfo{}, err
}
-
+ if opts.Checksum.IsSet() {
+ opts.AutoChecksum = opts.Checksum
+ }
withChecksum := c.trailingHeaderSupport
if withChecksum {
if opts.UserMetadata == nil {
@@ -304,6 +306,11 @@ func (c *Client) putObjectMultipartStreamOptionalChecksum(ctx context.Context, b
return UploadInfo{}, err
}
+ if opts.Checksum.IsSet() {
+ opts.AutoChecksum = opts.Checksum
+ opts.SendContentMd5 = false
+ }
+
if !opts.SendContentMd5 {
if opts.UserMetadata == nil {
opts.UserMetadata = make(map[string]string, 1)
@@ -463,7 +470,10 @@ func (c *Client) putObjectMultipartStreamParallel(ctx context.Context, bucketNam
if err = s3utils.CheckValidObjectName(objectName); err != nil {
return UploadInfo{}, err
}
-
+ if opts.Checksum.IsSet() {
+ opts.SendContentMd5 = false
+ opts.AutoChecksum = opts.Checksum
+ }
if !opts.SendContentMd5 {
if opts.UserMetadata == nil {
opts.UserMetadata = make(map[string]string, 1)
@@ -555,7 +565,7 @@ func (c *Client) putObjectMultipartStreamParallel(ctx context.Context, bucketNam
// Calculate md5sum.
customHeader := make(http.Header)
if !opts.SendContentMd5 {
- // Add CRC32C instead.
+ // Add Checksum instead.
crc.Reset()
crc.Write(buf[:length])
cSum := crc.Sum(nil)
@@ -677,6 +687,9 @@ func (c *Client) putObject(ctx context.Context, bucketName, objectName string, r
if opts.SendContentMd5 && s3utils.IsGoogleEndpoint(*c.endpointURL) && size < 0 {
return UploadInfo{}, errInvalidArgument("MD5Sum cannot be calculated with size '-1'")
}
+ if opts.Checksum.IsSet() {
+ opts.SendContentMd5 = false
+ }
var readSeeker io.Seeker
if size > 0 {
@@ -746,17 +759,6 @@ func (c *Client) putObjectDo(ctx context.Context, bucketName, objectName string,
// Set headers.
customHeader := opts.Header()
- // Add CRC when client supports it, MD5 is not set, not Google and we don't add SHA256 to chunks.
- addCrc := c.trailingHeaderSupport && md5Base64 == "" && !s3utils.IsGoogleEndpoint(*c.endpointURL) && (opts.DisableContentSha256 || c.secure)
-
- if addCrc {
- // If user has added checksums, don't add them ourselves.
- for k := range opts.UserMetadata {
- if strings.HasPrefix(strings.ToLower(k), "x-amz-checksum-") {
- addCrc = false
- }
- }
- }
// Populate request metadata.
reqMetadata := requestMetadata{
bucketName: bucketName,
@@ -768,10 +770,23 @@ func (c *Client) putObjectDo(ctx context.Context, bucketName, objectName string,
contentSHA256Hex: sha256Hex,
streamSha256: !opts.DisableContentSha256,
}
- if addCrc {
- opts.AutoChecksum.SetDefault(ChecksumCRC32C)
- reqMetadata.addCrc = &opts.AutoChecksum
+ // Add CRC when client supports it, MD5 is not set, not Google and we don't add SHA256 to chunks.
+ addCrc := c.trailingHeaderSupport && md5Base64 == "" && !s3utils.IsGoogleEndpoint(*c.endpointURL) && (opts.DisableContentSha256 || c.secure)
+ if opts.Checksum.IsSet() {
+ reqMetadata.addCrc = &opts.Checksum
+ } else if addCrc {
+ // If user has added checksums, don't add them ourselves.
+ for k := range opts.UserMetadata {
+ if strings.HasPrefix(strings.ToLower(k), "x-amz-checksum-") {
+ addCrc = false
+ }
+ }
+ if addCrc {
+ opts.AutoChecksum.SetDefault(ChecksumCRC32C)
+ reqMetadata.addCrc = &opts.AutoChecksum
+ }
}
+
if opts.Internal.SourceVersionID != "" {
if opts.Internal.SourceVersionID != nullVersionID {
if _, err := uuid.Parse(opts.Internal.SourceVersionID); err != nil {