From fa93945a4c34926a4d7d343dd01d706c2d1cd51d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Wed, 25 May 2022 13:54:26 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E9=98=BF=E9=87=8C=E4=BA=91=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=B8=8A=E4=BC=A0=E6=9C=AC=E5=9C=B0=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aliyun.go | 19 +++++++++++++++++++ version.go | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/aliyun.go b/aliyun.go index ad42d29..4f295fe 100644 --- a/aliyun.go +++ b/aliyun.go @@ -173,3 +173,22 @@ func (c *AliYun) PutObject(file io.Reader, filePath, fileName string) (resp File resp.Url = objectKey return } + +// PutLocalFile 上传本地文件 +// @param localFile 本地文件路径 +// @param filePath 文件路径 +// @param fileName 文件名称 +func (c *AliYun) PutLocalFile(localFilePath, filePath, fileName string) (resp FileInfo, err error) { + if localFilePath == "" { + return FileInfo{}, errors.New("localFilePath 不能为空") + } + objectKey := filePath + if fileName != "" { + objectKey = filePath + "/" + fileName + } + err = c.bucket.PutObjectFromFile(objectKey, localFilePath) + resp.Path = filePath + resp.Name = fileName + resp.Url = objectKey + return +} diff --git a/version.go b/version.go index d441a20..75fb6e6 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package gostorage -const Version = "1.0.6" +const Version = "1.0.7"