From 77887aa76b3c40bf50acf9ab90ee9fcc13cbb68d Mon Sep 17 00:00:00 2001 From: Yvan <8574526@qq,com> Date: Wed, 7 Jan 2026 10:17:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E4=B8=80=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/upload/aliyun.go | 8 ++++---- pkg/upload/aws.go | 8 ++++---- pkg/upload/cloudflare.go | 8 ++++---- pkg/upload/huawei.go | 8 ++++---- pkg/upload/local.go | 8 ++++---- pkg/upload/minio.go | 8 ++++---- pkg/upload/qiniu.go | 8 ++++---- pkg/upload/tencent.go | 8 ++++---- pkg/upload/upload.go | 4 ++-- 9 files changed, 34 insertions(+), 34 deletions(-) diff --git a/pkg/upload/aliyun.go b/pkg/upload/aliyun.go index ce047c2..15c548b 100644 --- a/pkg/upload/aliyun.go +++ b/pkg/upload/aliyun.go @@ -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 diff --git a/pkg/upload/aws.go b/pkg/upload/aws.go index 037f36b..75d8f20 100644 --- a/pkg/upload/aws.go +++ b/pkg/upload/aws.go @@ -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 { diff --git a/pkg/upload/cloudflare.go b/pkg/upload/cloudflare.go index bae4613..0a685e5 100644 --- a/pkg/upload/cloudflare.go +++ b/pkg/upload/cloudflare.go @@ -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 { diff --git a/pkg/upload/huawei.go b/pkg/upload/huawei.go index 8774099..c35cfe2 100644 --- a/pkg/upload/huawei.go +++ b/pkg/upload/huawei.go @@ -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 diff --git a/pkg/upload/local.go b/pkg/upload/local.go index 973f515..e686559 100644 --- a/pkg/upload/local.go +++ b/pkg/upload/local.go @@ -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) } diff --git a/pkg/upload/minio.go b/pkg/upload/minio.go index aa95705..f29046b 100644 --- a/pkg/upload/minio.go +++ b/pkg/upload/minio.go @@ -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 diff --git a/pkg/upload/qiniu.go b/pkg/upload/qiniu.go index 9a94446..110923b 100644 --- a/pkg/upload/qiniu.go +++ b/pkg/upload/qiniu.go @@ -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) diff --git a/pkg/upload/tencent.go b/pkg/upload/tencent.go index 0001d85..aaf9666 100644 --- a/pkg/upload/tencent.go +++ b/pkg/upload/tencent.go @@ -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 diff --git a/pkg/upload/upload.go b/pkg/upload/upload.go index 9bd95a1..6f6894f 100644 --- a/pkg/upload/upload.go +++ b/pkg/upload/upload.go @@ -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 上传配置