feat: create ads

This commit is contained in:
ericprd
2025-03-09 00:47:24 +08:00
parent 13c976dcbf
commit 213d370332
14 changed files with 289 additions and 0 deletions
+16
View File
@@ -68,3 +68,19 @@ func (r *OssRepositoryImpl) GetPublicURL(fileName string) string {
}
return fmt.Sprintf("%s:%s%s", r.cfg.GetPublicURL(), r.cfg.GetBucketName(), fileName)
}
func (r *OssRepositoryImpl) DeleteObject(ctx context.Context, fileName string) error {
if fileName == "" {
return fmt.Errorf("file name is not provided")
}
_, err := r.s3.DeleteObject(&s3.DeleteObjectInput{
Key: aws.String(fileName),
})
if err != nil {
return fmt.Errorf("failed to delete object %s from bucket: %v", fileName, err)
}
return nil
}
+1
View File
@@ -7,4 +7,5 @@ import (
type OSSRepository interface {
UploadFile(ctx context.Context, fileName string, fileContent []byte) (fileUrl string, err error)
GetPublicURL(fileName string) string
DeleteObject(ctx context.Context, fileName string) error
}