1
This commit is contained in:
@@ -15,8 +15,6 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
|
||||||
"github.com/qiniu/api.v7/storage"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -50,23 +48,24 @@ func Binary2Image(binaryData []byte, mimeType string) (img image.Image, outMimeT
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetQiniuUploadToken(ctx *jxcontext.Context, suffix, hashCode string) (upTokenInfo *UploadResTokenInfo, err error) {
|
func GetQiniuUploadToken(ctx *jxcontext.Context, suffix, hashCode string) (upTokenInfo *UploadResTokenInfo, err error) {
|
||||||
imgURL := ""
|
//imgURL := ""
|
||||||
if hashCode != "" {
|
//if hashCode != "" {
|
||||||
imgURL, _ = GetDataResource(ctx, hashCode)
|
// imgURL, _ = GetDataResource(ctx, hashCode)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
putPolicy := storage.PutPolicy{
|
//putPolicy := storage.PutPolicy{
|
||||||
Scope: globals.QiniuBucket,
|
// Scope: globals.QiniuBucket,
|
||||||
Expires: qiniuTokenExpires,
|
// Expires: qiniuTokenExpires,
|
||||||
}
|
//}
|
||||||
upTokenInfo = &UploadResTokenInfo{
|
//upTokenInfo = &UploadResTokenInfo{
|
||||||
Token: putPolicy.UploadToken(api.QiniuAPI),
|
// Token: putPolicy.UploadToken(api.QiniuAPI),
|
||||||
Expires: putPolicy.Expires,
|
// Expires: putPolicy.Expires,
|
||||||
FileName: jxutils.GenPicFileName(suffix),
|
// FileName: jxutils.GenPicFileName(suffix),
|
||||||
Hit: imgURL != "",
|
// Hit: imgURL != "",
|
||||||
Img: imgURL,
|
// Img: imgURL,
|
||||||
}
|
//}
|
||||||
return upTokenInfo, err
|
//return upTokenInfo, err
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 此函数要求resBinary不能空,mimeType与hashCode必须是正确的
|
// 此函数要求resBinary不能空,mimeType与hashCode必须是正确的
|
||||||
@@ -108,10 +107,10 @@ func RegisterDataResource(ctx *jxcontext.Context, name, resourceURL, mimeType, h
|
|||||||
return dataRes, err
|
return dataRes, err
|
||||||
}
|
}
|
||||||
if imgType > 0 {
|
if imgType > 0 {
|
||||||
if globals.EnableStoreWrite {
|
//if globals.EnableStoreWrite {
|
||||||
// 忽略上传错误
|
// 忽略上传错误
|
||||||
UploadImage2Vendors(ctx, nil, dataRes, resBinary, isAsyncUpload2Vendor)
|
UploadImage2Vendors(ctx, nil, dataRes, resBinary, isAsyncUpload2Vendor)
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
return dataRes, err
|
return dataRes, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,17 +7,11 @@ import (
|
|||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/globals/api2"
|
|
||||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||||
|
|
||||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/ebai"
|
|
||||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/jd"
|
|
||||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
testinit.Init()
|
testinit.Init()
|
||||||
api2.Init()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetQiniuUploadToken(t *testing.T) {
|
func TestGetQiniuUploadToken(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user