Deleting Objects in a Batch
API Description
You can use this API to batch delete objects from a specified bucket.
Method Definition
func (obsClient ObsClient) DeleteObjects(input *DeleteObjectsInput) (output *DeleteObjectsOutput, err error)
Method Definition If a Signed URL Is Used
func (obsClient ObsClient) DeleteObjectsWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *DeleteObjectsOutput, err error)
Request Parameter
| Field | Type | Optional or Mandatory |
|---|---|---|
| input | Mandatory |
Returned Result
| Field | Type |
|---|---|
| output | |
| err | error |
Sample Code
func main() { input := &obs.DeleteObjectsInput{} input.Bucket = "bucketname" var objects [3]obs.ObjectToDelete objects[0] = obs.ObjectToDelete{Key: "key1"} objects[1] = obs.ObjectToDelete{Key: "key2"} objects[2] = obs.ObjectToDelete{Key: "key3"} input.Objects = objects[:] output, err := obsClient.DeleteObjects(input) if err == nil { fmt.Printf("RequestId:%s\n", output.RequestId) for index, deleted := range output.Deleteds { fmt.Printf("Deleted[%d]-Key:%s, VersionId:%s\n", index, deleted.Key, deleted.VersionId) } for index, err := range output.Errors { fmt.Printf("Error[%d]-Key:%s, Code:%s\n", index, err.Key, err.Code) } } else { if obsError, ok := err.(obs.ObsError); ok { fmt.Println(obsError.Code) fmt.Println(obsError.Message) } else { fmt.Println(err) } } }
Last Article: Deleting an Object
Next Article: Obtaining Object Metadata
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.