MCPcopy
hub / github.com/minio/minio-go / abortMultipartUpload

Method abortMultipartUpload

api-remove.go:748–796  ·  view source on GitHub ↗

abortMultipartUpload aborts a multipart upload for the given uploadID, all previously uploaded parts are deleted.

(ctx context.Context, bucketName, objectName, uploadID string)

Source from the content-addressed store, hash-verified

746// abortMultipartUpload aborts a multipart upload for the given
747// uploadID, all previously uploaded parts are deleted.
748func (c *Client) abortMultipartUpload(ctx context.Context, bucketName, objectName, uploadID string) error {
749 // Input validation.
750 if err := s3utils.CheckValidBucketName(bucketName); err != nil {
751 return err
752 }
753 if err := s3utils.CheckValidObjectName(objectName); err != nil {
754 return err
755 }
756
757 // Initialize url queries.
758 urlValues := make(url.Values)
759 urlValues.Set("uploadId", uploadID)
760
761 // Execute DELETE on multipart upload.
762 resp, err := c.executeMethod(ctx, http.MethodDelete, requestMetadata{
763 bucketName: bucketName,
764 objectName: objectName,
765 queryValues: urlValues,
766 contentSHA256Hex: emptySHA256Hex,
767 })
768 defer closeResponse(resp)
769 if err != nil {
770 return err
771 }
772 if resp != nil {
773 if resp.StatusCode != http.StatusNoContent {
774 // Abort has no response body, handle it for any errors.
775 var errorResponse ErrorResponse
776 switch resp.StatusCode {
777 case http.StatusNotFound:
778 // This is needed specifically for abort and it cannot
779 // be converged into default case.
780 errorResponse = ErrorResponse{
781 Code: NoSuchUpload,
782 Message: "The specified multipart upload does not exist.",
783 BucketName: bucketName,
784 Key: objectName,
785 RequestID: resp.Header.Get("x-amz-request-id"),
786 HostID: resp.Header.Get("x-amz-id-2"),
787 Region: resp.Header.Get("x-amz-bucket-region"),
788 }
789 default:
790 return httpRespToErrorResponse(resp, bucketName, objectName)
791 }
792 return errorResponse
793 }
794 }
795 return nil
796}

Calls 7

executeMethodMethod · 0.95
CheckValidBucketNameFunction · 0.92
CheckValidObjectNameFunction · 0.92
httpRespToErrorResponseFunction · 0.85
closeResponseFunction · 0.70
SetMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected