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

Method removeObject

api-remove.go:153–216  ·  api-remove.go::Client.removeObject
(ctx context.Context, bucketName, objectName string, opts RemoveObjectOptions)

Source from the content-addressed store, hash-verified

151}
152
153func (c *Client) removeObject(ctx context.Context, bucketName, objectName string, opts RemoveObjectOptions) RemoveObjectResult {
154 // Get resources properly escaped and lined up before
155 // using them in http request.
156 urlValues := make(url.Values)
157
158 if opts.VersionID != "" {
159 urlValues.Set("versionId", opts.VersionID)
160 }
161
162 // Build headers.
163 headers := make(http.Header)
164
165 if opts.GovernanceBypass {
166 // Set the bypass goverenance retention header
167 headers.Set(amzBypassGovernance, "true")
168 }
169 if opts.Internal.ReplicationDeleteMarker {
170 headers.Set(minIOBucketReplicationDeleteMarker, "true")
171 }
172 if !opts.Internal.ReplicationMTime.IsZero() {
173 headers.Set(minIOBucketSourceMTime, opts.Internal.ReplicationMTime.Format(time.RFC3339Nano))
174 }
175 if !opts.Internal.ReplicationStatus.Empty() {
176 headers.Set(amzBucketReplicationStatus, string(opts.Internal.ReplicationStatus))
177 }
178 if opts.Internal.ReplicationRequest {
179 headers.Set(minIOBucketReplicationRequest, "true")
180 }
181 if opts.Internal.ReplicationValidityCheck {
182 headers.Set(minIOBucketReplicationCheck, "true")
183 }
184 if opts.ForceDelete {
185 headers.Set(minIOForceDelete, "true")
186 }
187 // Execute DELETE on objectName.
188 resp, err := c.executeMethod(ctx, http.MethodDelete, requestMetadata{
189 bucketName: bucketName,
190 objectName: objectName,
191 contentSHA256Hex: emptySHA256Hex,
192 queryValues: urlValues,
193 customHeader: headers,
194 })
195 defer closeResponse(resp)
196 if err != nil {
197 return RemoveObjectResult{Err: err}
198 }
199 if resp != nil {
200 // if some unexpected error happened and max retry is reached, we want to let client know
201 if resp.StatusCode != http.StatusNoContent {
202 err := httpRespToErrorResponse(resp, bucketName, objectName)
203 return RemoveObjectResult{Err: err}
204 }
205 }
206
207 // DeleteObject always responds with http '204' even for
208 // objects which do not exist. So no need to handle them
209 // specifically.
210 return RemoveObjectResult{

Callers 5

RemoveObjectMethod · 0.95
removeObjectsIterMethod · 0.95
removeObjectsMethod · 0.95
removeObjectsSingleMethod · 0.95

Calls 6

executeMethodMethod · 0.95
httpRespToErrorResponseFunction · 0.85
closeResponseFunction · 0.70
SetMethod · 0.45
EmptyMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected