批量删除对象
更新时间: 2019-03-13 10:20
功能说明
批量删除指定桶中的多个对象。
方法定义
- func (obsClient ObsClient) DeleteObjects(input *DeleteObjectsInput) (output *DeleteObjectsOutput, err error)
使用带授权信息URL的方法定义
- func (obsClient ObsClient) DeleteObjectsWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *DeleteObjectsOutput, err error)
请求参数
参数名 | 类型 | 约束 |
---|---|---|
input | *DeleteObjectsInput | 必选 |
返回结果
参数名 | 类型 |
---|---|
output | *DeleteObjectsOutput |
err | error |
代码样例
- 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)
- }
- }
- }
父主题:对象相关接口