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/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"github.com/qiniu/api.v7/storage"
|
||||
)
|
||||
|
||||
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) {
|
||||
imgURL := ""
|
||||
if hashCode != "" {
|
||||
imgURL, _ = GetDataResource(ctx, hashCode)
|
||||
}
|
||||
|
||||
putPolicy := storage.PutPolicy{
|
||||
Scope: globals.QiniuBucket,
|
||||
Expires: qiniuTokenExpires,
|
||||
}
|
||||
upTokenInfo = &UploadResTokenInfo{
|
||||
Token: putPolicy.UploadToken(api.QiniuAPI),
|
||||
Expires: putPolicy.Expires,
|
||||
FileName: jxutils.GenPicFileName(suffix),
|
||||
Hit: imgURL != "",
|
||||
Img: imgURL,
|
||||
}
|
||||
return upTokenInfo, err
|
||||
//imgURL := ""
|
||||
//if hashCode != "" {
|
||||
// imgURL, _ = GetDataResource(ctx, hashCode)
|
||||
//}
|
||||
//
|
||||
//putPolicy := storage.PutPolicy{
|
||||
// Scope: globals.QiniuBucket,
|
||||
// Expires: qiniuTokenExpires,
|
||||
//}
|
||||
//upTokenInfo = &UploadResTokenInfo{
|
||||
// Token: putPolicy.UploadToken(api.QiniuAPI),
|
||||
// Expires: putPolicy.Expires,
|
||||
// FileName: jxutils.GenPicFileName(suffix),
|
||||
// Hit: imgURL != "",
|
||||
// Img: imgURL,
|
||||
//}
|
||||
//return upTokenInfo, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 此函数要求resBinary不能空,mimeType与hashCode必须是正确的
|
||||
@@ -108,10 +107,10 @@ func RegisterDataResource(ctx *jxcontext.Context, name, resourceURL, mimeType, h
|
||||
return dataRes, err
|
||||
}
|
||||
if imgType > 0 {
|
||||
if globals.EnableStoreWrite {
|
||||
// 忽略上传错误
|
||||
UploadImage2Vendors(ctx, nil, dataRes, resBinary, isAsyncUpload2Vendor)
|
||||
}
|
||||
//if globals.EnableStoreWrite {
|
||||
// 忽略上传错误
|
||||
UploadImage2Vendors(ctx, nil, dataRes, resBinary, isAsyncUpload2Vendor)
|
||||
//}
|
||||
}
|
||||
return dataRes, err
|
||||
}
|
||||
|
||||
@@ -7,17 +7,11 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"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/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() {
|
||||
testinit.Init()
|
||||
api2.Init()
|
||||
}
|
||||
|
||||
func TestGetQiniuUploadToken(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user