Commit 7746414d by Li Feifei

修复中文文件名无法被解析

parent 61d555f3
Pipeline #15612 passed with stages
in 38 seconds
......@@ -47,9 +47,8 @@ func parseURL(ossFileLink, name string) (*parser, error) {
//解析课件的URL
func (f *parser) splitFileInfoLink() string {
return fmt.Sprintf("%s?info=0&ssl=1&furl=%s/%s",
ParserFileLink, g.Cfg().GetString("oss.url"), f.splitUploadPath() + gurl.Encode(f.slicePath[len(f.slicePath)-1:][0]))
return fmt.Sprintf("%s?info=0&ssl=1&furl=%s%s",
ParserFileLink, g.Cfg().GetString("oss.url"), f.dataPath())
}
// 临时存储解析包地址
......@@ -74,7 +73,7 @@ func (f *parser) contentHash() string {
// 数据库存储path
func (f *parser) dataPath() string {
return f.path[1:]
return "/" + f.splitUploadPath() + gurl.Encode(f.slicePath[len(f.slicePath)-1:][0])
}
// 解析doctype
......
......@@ -9,7 +9,6 @@ import (
"image/jpeg"
"image/png"
"io/ioutil"
"os"
"path"
"regexp"
"strings"
......@@ -155,6 +154,8 @@ func (f *ObtainFile) task(file *zip.File) error {
}
func (f *ObtainFile) uploadPicture() error {
fmt.Println(f.parser.splitTempZipLink())
reader, err := zip.OpenReader(f.parser.splitTempZipLink())
if err != nil {
return err
......@@ -194,7 +195,7 @@ func (f *ObtainFile) Worker(err error) {
downloadZipLink := fmt.Sprintf("%s?info=1&words=%v&ssl=1&furl=%s/%s",
ParserFileLink, f.pageCount, g.Cfg().GetString("oss.url"),
f.parser.dataPath)
f.parser.dataPath())
// 下载ZIP包
if err = http.Download(downloadZipLink, f.parser.splitTempZipLink()); err != nil {
......@@ -203,7 +204,7 @@ func (f *ObtainFile) Worker(err error) {
return
}
// 清理ZIP包
defer os.Remove(f.parser.splitTempZipLink())
//defer os.Remove(f.parser.splitTempZipLink())
g.Log().Async().Infof("file: %s Zip Donwload Complete", f.parser.name)
// 解析ZIP包并上传图片到OSS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment