Commit 306f230a by 宋毅

tj

parent 1a3a3fe3
...@@ -5,6 +5,12 @@ class AccessAuthAPI extends APIBase { ...@@ -5,6 +5,12 @@ class AccessAuthAPI extends APIBase {
super(); super();
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils"); this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
this.appmobilemsgSve = system.getObject("service.dbapp.appmobilemsgSve"); this.appmobilemsgSve = system.getObject("service.dbapp.appmobilemsgSve");
this.utilsappSve = system.getObject("service.utilsSve.utilsappSve");
}
async getOssInfo(pobj, qobj, req) {//获取oss信息
var result = await this.utilsappSve.getAppOssInfo(pobj);
return result;
} }
async getTokenByHosts(pobj, qobj, req) { async getTokenByHosts(pobj, qobj, req) {
......
var system = require("../../../system");
var settings = require("../../../../config/settings");
const AppServiceBase = require("../../app.base");
const crypto = require("crypto");
//商标查询操作
class UtilsAppSve extends AppServiceBase {
constructor() {
super();
this.appDao = system.getObject("db.dbapp.appDao");
}
async getAppOssInfo(pobj) {
var uapp_id = Number(pobj.appInfo.uapp_id || 0);
var sql = "SSELECT uapp_id,access_key_id,access_key_secret,file_url FROM `p_app_oss` WHERE is_enabled=1 and uapp_id in(:uapp_id)";
var paramWhere = { uapp_id: [uapp_id, 22] };
var list = await this.appDao(sql, paramWhere);
if (!list) {
return system.getResult(null, "oss info to data is empty !");
}
var ossIndex = list.findIndex(f => f.uapp_id == uapp_id);
if (ossIndex < 0) {
ossIndex = list.findIndex(f => f.uapp_id == 22);
}
if (ossIndex < 0) {
return system.getResult(null, "oss info to data is empty ! ! !");
}
var ossItem = list[ossIndex];
var bucket = pobj.actionBody.bucket || "gsb-zc";//oss 桶(即文件目录)
var end = new Date().getTime() + 36000000;//10小时-毫秒
var expiration = new Date(end).toISOString()
var policyText = {
"expiration": expiration,
"conditions": [
["content-length-range", 0, 1048576000],
["starts-with", "$key", "zc"]
]
};
var b = new Buffer(JSON.stringify(policyText));
var policyBase64 = b.toString('base64');
var signature = crypto.createHmac('sha1', ossItem.access_key_secret).update(policyBase64).digest().toString('base64'); //base64
var data = {
OSSAccessKeyId: ossItem.access_key_id,
policy: policyBase64,
Signature: signature,
Bucket: bucket,
success_action_status: 201,
url: ossItem.file_url
};
return system.getResultSuccess(data);
}
}
module.exports = UtilsAppSve;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment