feat: create ads
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user