Update upload.go
This commit is contained in:
commit
1714702304
@ -14,6 +14,7 @@ import (
|
|||||||
"fonchain-fiee/pkg/utils"
|
"fonchain-fiee/pkg/utils"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
|
cmdConf "fonchain-fiee/cmd/config"
|
||||||
"github.com/disintegration/imaging"
|
"github.com/disintegration/imaging"
|
||||||
"github.com/fonchain_enterprise/utils/objstorage"
|
"github.com/fonchain_enterprise/utils/objstorage"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@ -218,7 +219,7 @@ func quickBos(file *multipart.FileHeader, mediaType string, mask string, source
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var objectName string = fmt.Sprintf("%s/%s/%s", config.ConfigData.Oss.BaseDir, config.AppMode, filePath)
|
var objectName string = fmt.Sprintf("%s/%s/%s", config.ConfigData.Oss.BaseDir, cmdConf.AppConfig.System.AppMode, filePath)
|
||||||
BOSClient, _ := objstorage.NewOSS(os.Getenv(config.ConfigData.Oss.AccessKeyId), os.Getenv(config.ConfigData.Oss.AccessKeySecret), os.Getenv(config.ConfigData.Oss.Endpoint))
|
BOSClient, _ := objstorage.NewOSS(os.Getenv(config.ConfigData.Oss.AccessKeyId), os.Getenv(config.ConfigData.Oss.AccessKeySecret), os.Getenv(config.ConfigData.Oss.Endpoint))
|
||||||
_, err = BOSClient.PutObjectFromBytes(os.Getenv(config.ConfigData.Oss.BucketName), objectName, fileBytes)
|
_, err = BOSClient.PutObjectFromBytes(os.Getenv(config.ConfigData.Oss.BucketName), objectName, fileBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -293,7 +294,7 @@ func PutBos(filePath string, mediaType string, needRemove bool) (url string, err
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
filePath = strings.Replace(filePath, model.MediaPath, "", 1)
|
filePath = strings.Replace(filePath, model.MediaPath, "", 1)
|
||||||
var objectName string = fmt.Sprintf("%s/%s%s", config.ConfigData.Oss.BaseDir, config.AppMode, filePath)
|
var objectName string = fmt.Sprintf("%s/%s%s", config.ConfigData.Oss.BaseDir, cmdConf.AppConfig.System.AppMode, filePath)
|
||||||
_, err = BOSClient.PutObjectFromBytes(os.Getenv(config.ConfigData.Oss.BucketName), objectName, fileBytes)
|
_, err = BOSClient.PutObjectFromBytes(os.Getenv(config.ConfigData.Oss.BucketName), objectName, fileBytes)
|
||||||
//_, err = BOSClient.PutObjectFromBytes(config.ConfigData.Oss.BucketName, objectName, fileBytes)
|
//_, err = BOSClient.PutObjectFromBytes(config.ConfigData.Oss.BucketName, objectName, fileBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -363,7 +364,7 @@ func PutBosWithName(filePath string, needRemove bool, ossPath string) (url strin
|
|||||||
if ossPath == "" {
|
if ossPath == "" {
|
||||||
ossPath = filePath[1:]
|
ossPath = filePath[1:]
|
||||||
}
|
}
|
||||||
var objectName string = fmt.Sprintf("%s/%s%s", config.ConfigData.Oss.BaseDir, config.AppMode, ossPath)
|
var objectName string = fmt.Sprintf("%s/%s%s", config.ConfigData.Oss.BaseDir, cmdConf.AppConfig.System.AppMode, ossPath)
|
||||||
_, err = BOSClient.PutObject(os.Getenv(config.ConfigData.Oss.BucketName), objectName, filePath)
|
_, err = BOSClient.PutObject(os.Getenv(config.ConfigData.Oss.BucketName), objectName, filePath)
|
||||||
//_, err = BOSClient.PutObject(config.ConfigData.Oss.BucketName, objectName, filePath)
|
//_, err = BOSClient.PutObject(config.ConfigData.Oss.BucketName, objectName, filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user