任务一完成

This commit is contained in:
Yvan 2026-01-07 10:17:10 +08:00
parent 35ab7c0b70
commit 77887aa76b
9 changed files with 34 additions and 34 deletions

View File

@ -29,8 +29,8 @@ func NewAliyun(endpoint, accessKeyID, accessKeySecret, bucketName, bucketURL, ba
}
}
// Upload 上传文件
func (a *Aliyun) Upload(file *multipart.FileHeader) (string, string, error) {
// UploadFile 上传文件
func (a *Aliyun) UploadFile(file *multipart.FileHeader) (string, string, error) {
client, err := oss.New(a.Endpoint, a.AccessKeyID, a.AccessKeySecret)
if err != nil {
return "", "", err
@ -63,8 +63,8 @@ func (a *Aliyun) Upload(file *multipart.FileHeader) (string, string, error) {
return accessURL, key, nil
}
// Delete 删除文件
func (a *Aliyun) Delete(key string) error {
// DeleteFile 删除文件
func (a *Aliyun) DeleteFile(key string) error {
client, err := oss.New(a.Endpoint, a.AccessKeyID, a.AccessKeySecret)
if err != nil {
return err

View File

@ -57,8 +57,8 @@ func (a *AwsS3) getClient(ctx context.Context) (*s3.Client, error) {
return client, nil
}
// Upload 上传文件
func (a *AwsS3) Upload(file *multipart.FileHeader) (string, string, error) {
// UploadFile 上传文件
func (a *AwsS3) UploadFile(file *multipart.FileHeader) (string, string, error) {
ctx := context.Background()
client, err := a.getClient(ctx)
if err != nil {
@ -94,8 +94,8 @@ func (a *AwsS3) Upload(file *multipart.FileHeader) (string, string, error) {
return accessURL, key, nil
}
// Delete 删除文件
func (a *AwsS3) Delete(key string) error {
// DeleteFile 删除文件
func (a *AwsS3) DeleteFile(key string) error {
ctx := context.Background()
client, err := a.getClient(ctx)
if err != nil {

View File

@ -51,8 +51,8 @@ func (c *CloudflareR2) getClient(ctx context.Context) (*s3.Client, error) {
return client, nil
}
// Upload 上传文件
func (c *CloudflareR2) Upload(file *multipart.FileHeader) (string, string, error) {
// UploadFile 上传文件
func (c *CloudflareR2) UploadFile(file *multipart.FileHeader) (string, string, error) {
ctx := context.Background()
client, err := c.getClient(ctx)
if err != nil {
@ -88,8 +88,8 @@ func (c *CloudflareR2) Upload(file *multipart.FileHeader) (string, string, error
return accessURL, key, nil
}
// Delete 删除文件
func (c *CloudflareR2) Delete(key string) error {
// DeleteFile 删除文件
func (c *CloudflareR2) DeleteFile(key string) error {
ctx := context.Background()
client, err := c.getClient(ctx)
if err != nil {

View File

@ -31,8 +31,8 @@ func (h *HuaweiObs) getClient() (*obs.ObsClient, error) {
return obs.New(h.AccessKey, h.SecretKey, h.Endpoint)
}
// Upload 上传文件
func (h *HuaweiObs) Upload(file *multipart.FileHeader) (string, string, error) {
// UploadFile 上传文件
func (h *HuaweiObs) UploadFile(file *multipart.FileHeader) (string, string, error) {
client, err := h.getClient()
if err != nil {
return "", "", err
@ -66,8 +66,8 @@ func (h *HuaweiObs) Upload(file *multipart.FileHeader) (string, string, error) {
return accessURL, key, nil
}
// Delete 删除文件
func (h *HuaweiObs) Delete(key string) error {
// DeleteFile 删除文件
func (h *HuaweiObs) DeleteFile(key string) error {
client, err := h.getClient()
if err != nil {
return err

View File

@ -21,8 +21,8 @@ func NewLocal(storePath, basePath string) *Local {
}
}
// Upload 上传文件
func (l *Local) Upload(file *multipart.FileHeader) (string, string, error) {
// UploadFile 上传文件
func (l *Local) UploadFile(file *multipart.FileHeader) (string, string, error) {
// 生成文件名和路径
fileName := GenerateFileName(file.Filename)
filePath := GeneratePath(l.BasePath)
@ -59,8 +59,8 @@ func (l *Local) Upload(file *multipart.FileHeader) (string, string, error) {
return accessPath, key, nil
}
// Delete 删除文件
func (l *Local) Delete(key string) error {
// DeleteFile 删除文件
func (l *Local) DeleteFile(key string) error {
fullPath := path.Join(l.StorePath, key)
return os.Remove(fullPath)
}

View File

@ -38,8 +38,8 @@ func (m *Minio) getClient() (*minio.Client, error) {
})
}
// Upload 上传文件
func (m *Minio) Upload(file *multipart.FileHeader) (string, string, error) {
// UploadFile 上传文件
func (m *Minio) UploadFile(file *multipart.FileHeader) (string, string, error) {
client, err := m.getClient()
if err != nil {
return "", "", err
@ -74,8 +74,8 @@ func (m *Minio) Upload(file *multipart.FileHeader) (string, string, error) {
return accessURL, key, nil
}
// Delete 删除文件
func (m *Minio) Delete(key string) error {
// DeleteFile 删除文件
func (m *Minio) DeleteFile(key string) error {
client, err := m.getClient()
if err != nil {
return err

View File

@ -50,8 +50,8 @@ func (q *Qiniu) getZone() *storage.Region {
}
}
// Upload 上传文件
func (q *Qiniu) Upload(file *multipart.FileHeader) (string, string, error) {
// UploadFile 上传文件
func (q *Qiniu) UploadFile(file *multipart.FileHeader) (string, string, error) {
mac := qbox.NewMac(q.AccessKey, q.SecretKey)
putPolicy := storage.PutPolicy{Scope: q.Bucket}
upToken := putPolicy.UploadToken(mac)
@ -87,8 +87,8 @@ func (q *Qiniu) Upload(file *multipart.FileHeader) (string, string, error) {
return accessURL, key, nil
}
// Delete 删除文件
func (q *Qiniu) Delete(key string) error {
// DeleteFile 删除文件
func (q *Qiniu) DeleteFile(key string) error {
mac := qbox.NewMac(q.AccessKey, q.SecretKey)
cfg := storage.Config{Zone: q.getZone()}
bucketManager := storage.NewBucketManager(mac, &cfg)

View File

@ -44,8 +44,8 @@ func (t *Tencent) getClient() *cos.Client {
})
}
// Upload 上传文件
func (t *Tencent) Upload(file *multipart.FileHeader) (string, string, error) {
// UploadFile 上传文件
func (t *Tencent) UploadFile(file *multipart.FileHeader) (string, string, error) {
client := t.getClient()
// 生成文件名和路径
@ -71,8 +71,8 @@ func (t *Tencent) Upload(file *multipart.FileHeader) (string, string, error) {
return accessURL, key, nil
}
// Delete 删除文件
func (t *Tencent) Delete(key string) error {
// DeleteFile 删除文件
func (t *Tencent) DeleteFile(key string) error {
client := t.getClient()
_, err := client.Object.Delete(context.Background(), key)
return err

View File

@ -18,8 +18,8 @@ var (
// OSS 对象存储接口
type OSS interface {
Upload(file *multipart.FileHeader) (string, string, error)
Delete(key string) error
UploadFile(file *multipart.FileHeader) (string, string, error)
DeleteFile(key string) error
}
// Config 上传配置