n8n-nodes-feishu-lark
Version:
n8n custom nodes for n8n to interact with Feishu/Lark, including Lark Bot, Lark MCP, and Lark Trigger.
56 lines • 2.46 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.UploadFile,
value: "uploadFile",
order: 191,
options: [
description_1.DESCRIPTIONS.MESSAGE_UPLOAD_FILE_TYPE,
description_1.DESCRIPTIONS.FILE_DURATION,
description_1.DESCRIPTIONS.BINARY_PROPERTY_NAME,
{
displayName: wording_1.WORDING.Options,
name: 'options',
type: 'collection',
placeholder: wording_1.WORDING.AddField,
default: {},
options: [description_1.DESCRIPTIONS.FILE_NAME],
},
{
displayName: `<a target="_blank" href="https://open.feishu.cn/document/server-docs/im-v1/file/create">${wording_1.WORDING.OpenDocument}</a>`,
name: 'notice',
type: 'notice',
default: '',
},
],
async call(index) {
const fileType = this.getNodeParameter('file_type', index);
const options = this.getNodeParameter('options', index, {});
const fileDuration = options.file_duration;
const fileName = options.file_name;
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', index);
const dataBuffer = await this.helpers.getBinaryDataBuffer(index, binaryPropertyName);
const formData = new form_data_1.default();
formData.append('file_type', fileType);
if (fileDuration) {
formData.append('file_duration', (fileDuration === null || fileDuration === void 0 ? void 0 : fileDuration.toString()) || '0');
}
formData.append('file_name', fileName || `file-${Date.now()}-${Math.floor(Math.random() * 100000)}.${fileType}`);
formData.append('file', dataBuffer);
const { data } = await RequestUtils_1.default.request.call(this, {
method: 'POST',
url: `/open-apis/im/v1/files`,
body: formData,
json: true,
});
return data;
},
};
//# sourceMappingURL=FileUpload.operation.js.map