1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| package upload
|
| import (
| "time"
| "wms/conf"
| "wms/pkg/logx"
| "wms/pkg/weedfs"
| )
|
| func UploadFileToSeaWeed(fileType, fileName string, fileBytes []byte) (string, error) {
| //assignUrl := conf.WebConf.FileServer + "/dir/assign?collection=" + time.Now().Format("2006-01-02 15:04:05")[:10] + "-" + conf.WebConf.ServerId + "-" + fileType
| assignUrl := conf.WebConf.FileServer + "/dir/assign?collection=12345-" + conf.WebConf.ServerId + "-" + fileType
|
| picUrl, err := WeedFSClient.GetFid(assignUrl)
| if err != nil {
| logx.Error(err.Error())
| return picUrl, err
| }
|
| //picFileName := uuid.NewV4().String() + "." + ext
| go WeedFSClient.UploadFile(picUrl, fileName, fileBytes, 3*time.Second)
| return picUrl, nil
| }
|
|