"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const assert_1 = require("oak-domain/lib/utils/assert"); const Exception_1 = require("../../types/Exception"); const Exception_2 = require("oak-domain/lib/types/Exception"); class Wechat { name = 'wechat'; autoInform() { return false; } getConfig(application) { (0, assert_1.assert)(application.type === 'wechatPublic'); const config = application.config; return { config: config, type: application.type, }; } async upload(options) { const { extraFile, uploadFn, file, uploadToAspect, getPercent } = options; (0, assert_1.assert)(extraFile.enableChunkedUpload !== true, '暂不支持分片上传'); let result; const { applicationId, type, extra2, id } = extraFile; (0, assert_1.assert)(type === 'image'); try { result = (await uploadToAspect(file, 'file', 'uploadWechatMedia', { applicationId, type, isPermanent: extra2?.isPermanent || false, extraFileId: id, }, true)); } catch (err) { // 网络错误 throw new Exception_2.OakNetworkException('网络异常,请求失败'); } // 解析回调 if (result.mediaId) { return; } else { throw new Exception_1.OakUploadException('文件上传微信失败'); } } composeFileUrl(options) { return ''; } } exports.default = Wechat; ;