n8n-nodes-feishu-lark
Version:
n8n custom nodes for n8n to interact with Feishu/Lark, including Lark Bot, Lark MCP, and Lark Trigger.
64 lines • 2.67 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const form_data_1 = __importDefault(require("form-data"));
const RequestUtils_1 = __importDefault(require("../../../help/utils/RequestUtils"));
const wording_1 = require("../../../help/wording");
const description_1 = require("../../../help/description");
exports.default = {
name: wording_1.WORDING.UploadMedia,
value: "uploadMedia",
order: 160,
options: [
description_1.DESCRIPTIONS.PARENT_TYPE,
description_1.DESCRIPTIONS.PARENT_NODE,
description_1.DESCRIPTIONS.FILE_BINARY_FIELD,
{
displayName: wording_1.WORDING.Options,
name: 'options',
type: 'collection',
placeholder: wording_1.WORDING.AddField,
default: {},
options: [
{
...description_1.DESCRIPTIONS.REQUEST_BODY,
name: 'media_upload_extra',
},
],
},
{
displayName: `<a target="_blank" href="https://open.feishu.cn/document/server-docs/docs/drive-v1/media/upload_all">${wording_1.WORDING.OpenDocument}</a>`,
name: 'notice',
type: 'notice',
default: '',
},
],
async call(index) {
const parentType = this.getNodeParameter('parent_type', index);
const parentNode = this.getNodeParameter('parent_node', index);
const fileBinaryField = this.getNodeParameter('file_binary_field', index);
const binaryData = await this.helpers.assertBinaryData(index, fileBinaryField);
const buffer = await this.helpers.getBinaryDataBuffer(index, fileBinaryField);
const options = this.getNodeParameter('options', index, {});
const extra = options.media_upload_extra || undefined;
const formData = new form_data_1.default();
formData.append('file_name', binaryData.fileName);
formData.append('parent_type', parentType);
formData.append('parent_node', parentNode);
formData.append('size', buffer.length);
formData.append('file', buffer);
if (extra) {
formData.append('extra', JSON.stringify(extra));
}
const { data } = await RequestUtils_1.default.request.call(this, {
method: 'POST',
url: '/open-apis/drive/v1/medias/upload_all',
body: formData,
json: true,
});
return data;
},
};
//# sourceMappingURL=MediaUpload.operation.js.map