n8n-nodes-feishu-lark
Version:
n8n custom nodes for n8n to interact with Feishu/Lark, including Lark Bot, Lark MCP, and Lark Trigger.
68 lines • 2.6 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
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.DownloadMedia,
value: "downloadMedia",
order: 150,
options: [
description_1.DESCRIPTIONS.MEDIA_FILE_TOKEN,
description_1.DESCRIPTIONS.OUTPUT_AS_BINARY,
{
displayName: wording_1.WORDING.Options,
name: 'options',
type: 'collection',
placeholder: wording_1.WORDING.AddField,
default: {},
options: [
{
...description_1.DESCRIPTIONS.REQUEST_BODY,
name: 'media_download_extra',
},
],
},
{
displayName: `<a target="_blank" href="https://open.feishu.cn/document/server-docs/docs/drive-v1/media/download">${wording_1.WORDING.OpenDocument}</a>`,
name: 'notice',
type: 'notice',
default: '',
},
],
async call(index) {
const fileToken = this.getNodeParameter('media_file_token', index);
const outputAsBinary = this.getNodeParameter('outputAsBinary', index, true);
const options = this.getNodeParameter('options', index, {});
const extra = options.media_download_extra || undefined;
const buffer = await RequestUtils_1.default.request.call(this, {
method: 'GET',
url: `/open-apis/drive/v1/medias/${fileToken}/download`,
encoding: 'arraybuffer',
json: false,
qs: {
...(extra && { extra: JSON.stringify(extra) }),
},
});
const binaryData = await this.helpers.prepareBinaryData(buffer);
if (outputAsBinary) {
return {
outputType: "binary",
binaryData,
binaryPropertyName: 'data',
};
}
const base64Data = Buffer.from(buffer).toString('base64');
return {
data: base64Data,
mimeType: binaryData.mimeType,
fileName: binaryData.fileName,
fileExtension: binaryData.fileExtension,
fileSize: binaryData.fileSize,
};
},
};
//# sourceMappingURL=MediaDownload.operation.js.map