fix:文件上传--base64
This commit is contained in:
parent
869873deda
commit
3d82709b7e
|
@ -1,13 +1,12 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/file"
|
||||
"fusenapi/utils/hash"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"context"
|
||||
|
@ -97,12 +96,11 @@ func (l *UploadFileBaseLogic) UploadFileBase(req *types.UploadFileBaseReq, useri
|
|||
uploadUrl.ResourceId = resourceId
|
||||
uploadUrl.ResourceUrl = *resourceInfo.ResourceUrl
|
||||
} else {
|
||||
RBase64Point := strings.LastIndex(req.FileData, ";base64,") + 8
|
||||
req.FileData = req.FileData[RBase64Point:]
|
||||
dist, err := base64.StdEncoding.DecodeString(req.FileData)
|
||||
dist, err := file.FileBase64ToByte(req.FileData)
|
||||
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,base64tobyte error")
|
||||
}
|
||||
|
||||
// 创建S3对象存储请求
|
||||
|
|
17
utils/file/base64.go
Normal file
17
utils/file/base64.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package file
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func FileBase64ToByte(fileData string) ([]byte, error) {
|
||||
RBase64Point := strings.LastIndex(fileData, ";base64,") + 8
|
||||
fileDataStr := fileData[RBase64Point:]
|
||||
dist, err := base64.StdEncoding.DecodeString(fileDataStr)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dist, nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user