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

Method RemoveObjects

api-remove.go:305–343  ·  view source on GitHub ↗

RemoveObjects removes multiple objects from a bucket while it is possible to specify objects versions which are received from objectsCh. Remove failures are sent back via error channel.

(ctx context.Context, bucketName string, objectsCh <-chan ObjectInfo, opts RemoveObjectsOptions)

Source from the content-addressed store, hash-verified

303// it is possible to specify objects versions which are received from
304// objectsCh. Remove failures are sent back via error channel.
305func (c *Client) RemoveObjects(ctx context.Context, bucketName string, objectsCh <-chan ObjectInfo, opts RemoveObjectsOptions) <-chan RemoveObjectError {
306 errorCh := make(chan RemoveObjectError, 1)
307
308 // Validate if bucket name is valid.
309 if err := s3utils.CheckValidBucketName(bucketName); err != nil {
310 defer close(errorCh)
311 errorCh <- RemoveObjectError{
312 Err: err,
313 }
314 return errorCh
315 }
316 // Validate objects channel to be properly allocated.
317 if objectsCh == nil {
318 defer close(errorCh)
319 errorCh <- RemoveObjectError{
320 Err: errInvalidArgument("Objects channel cannot be nil"),
321 }
322 return errorCh
323 }
324
325 resultCh := make(chan RemoveObjectResult, 1)
326 go c.removeObjects(ctx, bucketName, objectsCh, resultCh, opts)
327 go func() {
328 defer close(errorCh)
329 for res := range resultCh {
330 // Send only errors to the error channel
331 if res.Err == nil {
332 continue
333 }
334 errorCh <- RemoveObjectError{
335 ObjectName: res.ObjectName,
336 VersionID: res.ObjectVersionID,
337 Err: res.Err,
338 }
339 }
340 }()
341
342 return errorCh
343}
344
345// RemoveObjectsWithIter bulk deletes multiple objects from a bucket.
346// Objects (with optional versions) to be removed must be provided with

Callers 6

testRemoveObjectsContextFunction · 0.95
testRemoveObjectsFunction · 0.95
mainFunction · 0.80

Calls 3

removeObjectsMethod · 0.95
CheckValidBucketNameFunction · 0.92
errInvalidArgumentFunction · 0.85

Tested by 1