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"