summaryrefslogtreecommitdiff
path: root/vendor/github.com/minio/minio-go/v7/api-put-object-streaming.go
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-07-22 18:00:27 +0200
committerLibravatar kim <gruf@noreply.codeberg.org>2025-07-22 18:00:27 +0200
commitc00cad2cebcb8136a998f6f7ba2c27672f785d10 (patch)
tree863516d8459713cc4b91c83d8aeeef3cac486b39 /vendor/github.com/minio/minio-go/v7/api-put-object-streaming.go
parent[chore/deps] Upgrade to go-sqlite 0.27.1 (#4334) (diff)
downloadgotosocial-c00cad2cebcb8136a998f6f7ba2c27672f785d10.tar.xz
[chore] bump dependencies (#4339)
- github.com/KimMachineGun/automemlimit v0.7.4 - github.com/miekg/dns v1.1.67 - github.com/minio/minio-go/v7 v7.0.95 - github.com/spf13/pflag v1.0.7 - github.com/tdewolff/minify/v2 v2.23.9 - github.com/uptrace/bun v1.2.15 - github.com/uptrace/bun/dialect/pgdialect v1.2.15 - github.com/uptrace/bun/dialect/sqlitedialect v1.2.15 - github.com/uptrace/bun/extra/bunotel v1.2.15 - golang.org/x/image v0.29.0 - golang.org/x/net v0.42.0 Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4339 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
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.go68
1 files changed, 26 insertions, 42 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 4a7243edc..db5314d5f 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,19 +108,14 @@ 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 {
- addAutoChecksumHeaders(&opts)
- }
+
// Initiate a new multipart upload.
uploadID, err := c.newUploadID(ctx, bucketName, objectName, opts)
if err != nil {
return UploadInfo{}, err
}
- delete(opts.UserMetadata, "X-Amz-Checksum-Algorithm")
+
+ withChecksum := c.trailingHeaderSupport
// Aborts the multipart upload in progress, if the
// function returns any error, since we do not resume
@@ -297,15 +292,6 @@ 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 {
- addAutoChecksumHeaders(&opts)
- }
-
// Calculate the optimal parts info for a given size.
totalPartsCount, partSize, lastPartSize, err := OptimalPartInfo(size, opts.PartSize)
if err != nil {
@@ -316,7 +302,6 @@ func (c *Client) putObjectMultipartStreamOptionalChecksum(ctx context.Context, b
if err != nil {
return UploadInfo{}, err
}
- delete(opts.UserMetadata, "X-Amz-Checksum-Algorithm")
// Aborts the multipart upload if the function returns
// any error, since we do not resume we should purge
@@ -369,12 +354,18 @@ func (c *Client) putObjectMultipartStreamOptionalChecksum(ctx context.Context, b
md5Hash.Reset()
md5Hash.Write(buf[:length])
md5Base64 = base64.StdEncoding.EncodeToString(md5Hash.Sum(nil))
- } else {
+ }
+
+ if opts.AutoChecksum.IsSet() {
// Add CRC32C instead.
crc.Reset()
crc.Write(buf[:length])
cSum := crc.Sum(nil)
- customHeader.Set(opts.AutoChecksum.KeyCapitalized(), base64.StdEncoding.EncodeToString(cSum))
+ customHeader.Set(opts.AutoChecksum.Key(), base64.StdEncoding.EncodeToString(cSum))
+ customHeader.Set(amzChecksumAlgo, opts.AutoChecksum.String())
+ if opts.AutoChecksum.FullObjectRequested() {
+ customHeader.Set(amzChecksumMode, ChecksumFullObjectMode.String())
+ }
}
// Update progress reader appropriately to the latest offset
@@ -453,13 +444,6 @@ 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 {
- addAutoChecksumHeaders(&opts)
- }
// Cancel all when an error occurs.
ctx, cancel := context.WithCancel(ctx)
@@ -476,7 +460,6 @@ func (c *Client) putObjectMultipartStreamParallel(ctx context.Context, bucketNam
if err != nil {
return UploadInfo{}, err
}
- delete(opts.UserMetadata, "X-Amz-Checksum-Algorithm")
// Aborts the multipart upload if the function returns
// any error, since we do not resume we should purge
@@ -541,18 +524,22 @@ func (c *Client) putObjectMultipartStreamParallel(ctx context.Context, bucketNam
return UploadInfo{}, rerr
}
- // Calculate md5sum.
- customHeader := make(http.Header)
- if !opts.SendContentMd5 {
- // Add Checksum instead.
- crc.Reset()
- crc.Write(buf[:length])
- cSum := crc.Sum(nil)
- customHeader.Set(opts.AutoChecksum.Key(), base64.StdEncoding.EncodeToString(cSum))
- }
-
wg.Add(1)
go func(partNumber int) {
+ // Calculate md5sum.
+ customHeader := make(http.Header)
+ if opts.AutoChecksum.IsSet() {
+ // Add Checksum instead.
+ crc.Reset()
+ crc.Write(buf[:length])
+ cSum := crc.Sum(nil)
+ customHeader.Set(opts.AutoChecksum.Key(), base64.StdEncoding.EncodeToString(cSum))
+ customHeader.Set(amzChecksumAlgo, opts.AutoChecksum.String())
+ if opts.AutoChecksum.FullObjectRequested() {
+ customHeader.Set(amzChecksumMode, ChecksumFullObjectMode.String())
+ }
+ }
+
// Avoid declaring variables in the for loop
var md5Base64 string
@@ -664,9 +651,6 @@ 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 {
@@ -759,7 +743,7 @@ func (c *Client) putObjectDo(ctx context.Context, bucketName, objectName string,
}
}
if addCrc {
- opts.AutoChecksum.SetDefault(ChecksumCRC32C)
+ opts.AutoChecksum.SetDefault(ChecksumFullObjectCRC32C)
reqMetadata.addCrc = &opts.AutoChecksum
}
}