mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-30 17:12:25 -05:00 
			
		
		
		
	[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
This commit is contained in:
		
					parent
					
						
							
								b0fbc327f0
							
						
					
				
			
			
				commit
				
					
						53ee6aef08
					
				
			
		
					 15 changed files with 433 additions and 210 deletions
				
			
		
							
								
								
									
										49
									
								
								vendor/github.com/minio/minio-go/v7/api-put-object-streaming.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										49
									
								
								vendor/github.com/minio/minio-go/v7/api-put-object-streaming.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -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 { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue