|
@@ -4,7 +4,9 @@ import (
|
|
|
"crypto/sha256"
|
|
|
"fmt"
|
|
|
"io"
|
|
|
+ "net/url"
|
|
|
"os"
|
|
|
+ "path/filepath"
|
|
|
|
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
@@ -32,8 +34,12 @@ func OssPutObject(objectName string, fd io.Reader, ossBucketName string) (bool,
|
|
|
logx.Error("Error:", err)
|
|
|
return false, err
|
|
|
}
|
|
|
+ fileNameOnly := getFileNameOnly(objectName)
|
|
|
+ fileExtension := TypeByExt(objectName)
|
|
|
+
|
|
|
option := []oss.Option{
|
|
|
- oss.ContentDisposition("attachment;filename=" + objectName),
|
|
|
+ // oss.ContentDisposition("attachment;filename=" + objectName),
|
|
|
+ oss.ContentDisposition("attachment;filename=" + url.QueryEscape(fileNameOnly) + "." + fileExtension + ";filename*=UTF-8''" + url.QueryEscape(fileNameOnly) + "." + fileExtension),
|
|
|
oss.ContentType("application/octet-stream"),
|
|
|
oss.ACReqHeaders("Access-Control-Allow-Origin"),
|
|
|
oss.ACReqMethod("*"),
|
|
@@ -83,3 +89,10 @@ func TypeByExt(path string) string {
|
|
|
}
|
|
|
return ""
|
|
|
}
|
|
|
+
|
|
|
+// 获取文件名称(不带后缀)
|
|
|
+func getFileNameOnly(filename string) string {
|
|
|
+ extension := filepath.Ext(filename)
|
|
|
+ fileNameOnly := filename[0 : len(filename)-len(extension)]
|
|
|
+ return fileNameOnly
|
|
|
+}
|