n8n-nodes-wechat-work
Version:
48 lines • 1.97 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const WechatWorkRequestUtils_1 = __importDefault(require("../../../help/utils/WechatWorkRequestUtils"));
const MediaUploadImageOperate = {
name: '上传图片',
value: 'media:uploadImage',
description: '上传图片得到图片URL,该URL永久有效',
options: [
{
displayName: '文件',
name: 'inputDataFieldName',
type: 'string',
placeholder: 'e.g. data',
default: 'data',
hint: '包含用于更新文件的二进制文件数据的输入字段的名称',
description: '在左侧输入面板的二进制选项卡中,找到包含二进制数据的输入字段的名称,以更新文件',
required: true,
},
],
async call(index) {
const inputDataFieldName = this.getNodeParameter('inputDataFieldName', index);
const binaryData = this.helpers.assertBinaryData(index, inputDataFieldName);
if (!binaryData) {
throw new Error('未找到二进制数据');
}
const buffer = await this.helpers.getBinaryDataBuffer(index, inputDataFieldName);
return WechatWorkRequestUtils_1.default.request.call(this, {
method: 'POST',
url: `/cgi-bin/media/uploadimg`,
json: false,
formData: {
media: {
value: buffer,
options: {
filename: binaryData.fileName,
filelength: binaryData.fileSize,
contentType: binaryData.mimeType,
},
},
},
});
},
};
exports.default = MediaUploadImageOperate;
//# sourceMappingURL=MediaUploadImageOperate.js.map