阿里云oss添加删除接口

This commit is contained in:
lzh
2025-07-16 14:12:11 +08:00
parent c214b6c94a
commit 0c7ec61e65
2 changed files with 28 additions and 0 deletions

View File

@@ -145,3 +145,18 @@ func (c *ALiYunOSSClient) GetObjectToImage(bucket string, key string) (img image
}
return img, nil
}
// DelObject 删除对象
func (c *ALiYunOSSClient) DelObject(bucket string, key string) (err error) {
// 创建删除对象的请求
request := &oss.DeleteObjectRequest{
Bucket: oss.Ptr(bucket), // 存储空间名称
Key: oss.Ptr(key), // 对象名称
}
// 执行删除对象的操作并处理结果
_, err = c.ossClient.DeleteObject(context.TODO(), request)
if err != nil {
return err
}
return nil
}