From 5e75094c1647075505fc74de93392e6f32e6ae18 Mon Sep 17 00:00:00 2001 From: ayflying Date: Wed, 11 Jun 2025 19:11:50 +0800 Subject: [PATCH] =?UTF-8?q?s3=E4=BD=BF=E7=94=A8=E8=87=AA=E5=8A=A8=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/s3/s3.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/pkg/s3/s3.go b/pkg/s3/s3.go index 62d5cea..5f18a2c 100644 --- a/pkg/s3/s3.go +++ b/pkg/s3/s3.go @@ -63,9 +63,9 @@ func New(_name ...string) *Mod { obj, err := minio.New( cfg.Address, &minio.Options{ - Creds: credentials.NewStaticV4(cfg.AccessKey, cfg.SecretKey, ""), - Secure: cfg.Ssl, - BucketLookup: minio.BucketLookupPath, + Creds: credentials.NewStaticV4(cfg.AccessKey, cfg.SecretKey, ""), + Secure: cfg.Ssl, + //BucketLookup: minio.BucketLookupPath, }, ) if err != nil { @@ -135,9 +135,9 @@ func (s *Mod) ListBuckets() []minio.BucketInfo { func (s *Mod) PutObject(f io.Reader, name string, bucketName string, _size ...int64) (res minio.UploadInfo, err error) { // 初始化文件大小为 -1,表示将读取文件至结束 var size = int64(-1) - if len(_size) > 0 { - size = _size[0] - } + //if len(_size) > 0 { + // size = _size[0] + //} // 调用 S3 客户端上传文件,设置内容类型为 "application/octet-stream" res, err = s.client.PutObject(ctx, bucketName, name, f, size, minio.PutObjectOptions{ //ContentType: "application/octet-stream", @@ -192,12 +192,13 @@ func (s *Mod) GetUrl(filePath string, defaultFile ...string) (url string) { filePath = defaultFile[0] } - switch s.cfg.Provider { - case "qiniu": - url = get + path.Join(bucketName, filePath) - default: - url = get + filePath - } + //switch s.cfg.Provider { + //case "qiniu": + // url = get + path.Join(bucketName, filePath) + //default: + // url = get + filePath + //} + url = get + filePath if !s.cfg.Ssl { url = get + path.Join(bucketName, filePath)