1
This commit is contained in:
@@ -3,6 +3,8 @@ package datares
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
"github.com/qiniu/api.v7/storage"
|
||||||
"image"
|
"image"
|
||||||
"image/gif"
|
"image/gif"
|
||||||
"image/jpeg"
|
"image/jpeg"
|
||||||
@@ -49,26 +51,25 @@ func Binary2Image(binaryData []byte, mimeType string) (img image.Image, outMimeT
|
|||||||
return img, mimeType, err
|
return img, mimeType, err
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
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
|
}
|
||||||
//}
|
|
||||||
|
|
||||||
// 此函数要求resBinary不能空,mimeType与hashCode必须是正确的
|
// 此函数要求resBinary不能空,mimeType与hashCode必须是正确的
|
||||||
func RegisterDataResource(ctx *jxcontext.Context, name, resourceURL, mimeType, hashCode string, resBinary []byte, imgType int, isAsyncUpload2Vendor bool) (dataRes *model.DataResource, err error) {
|
func RegisterDataResource(ctx *jxcontext.Context, name, resourceURL, mimeType, hashCode string, resBinary []byte, imgType int, isAsyncUpload2Vendor bool) (dataRes *model.DataResource, err error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user