✨ feat(活动): 添加关注豪礼
This commit is contained in:
@@ -15,6 +15,7 @@ const publishPath = '/root/hot_update_backup';
|
||||
import {exec} from 'child_process'
|
||||
import { reloadResources } from '@pubUtils/data';
|
||||
import { decodeArrayStr } from '@pubUtils/util';
|
||||
import { getLocalQrCodeUrl, getRemoteQrCodeUrl } from '@pubUtils/battleUtils';
|
||||
const sendToWormhole = require('stream-wormhole');
|
||||
|
||||
export default class UploadController extends Controller {
|
||||
@@ -276,6 +277,49 @@ export default class UploadController extends Controller {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public async uploadQrCode() {
|
||||
const { ctx } = this;
|
||||
|
||||
try {
|
||||
const { ctx } = this;
|
||||
const parts = ctx.multipart();
|
||||
let part, env = ctx.request.headers.env, fileName = '';
|
||||
while ((part = await parts()) != null) {
|
||||
if (part.length) {
|
||||
console.log('kv: ', `${part[0]}: ${part[1]}`);
|
||||
} else {
|
||||
if (!part.filename) continue;
|
||||
|
||||
let filenames = part.filename.split('.');
|
||||
let ext = filenames[filenames.length - 1];
|
||||
let writePath = getLocalQrCodeUrl(this.app.config.realEnv, env);
|
||||
fileName = `QR${moment().valueOf()}.${ext}`;
|
||||
let fullPath = `${writePath}/${fileName}`;
|
||||
try {
|
||||
fs.accessSync(writePath);
|
||||
} catch (err) {
|
||||
if (err) {
|
||||
fs.mkdirSync(writePath, { recursive: true });
|
||||
}
|
||||
}
|
||||
if (!fs.existsSync(fullPath)) {
|
||||
fs.writeFileSync(fullPath, '');
|
||||
}
|
||||
const writeStream = fs.createWriteStream(fullPath);
|
||||
await pump(part, writeStream);
|
||||
|
||||
// remoteUrl = `${getRemoteRplUrl(ctx.app.config.realEnv, roleId, warType, battleCode)}/${battleCode}.bin`;
|
||||
}
|
||||
await sendToWormhole(part);
|
||||
}
|
||||
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { isOK: true, url: getRemoteQrCodeUrl(env, fileName) });
|
||||
return;
|
||||
} catch(e) {
|
||||
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { isOK: false, err: e.stack });
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function childExec(commond: string) {
|
||||
|
||||
Reference in New Issue
Block a user