MCPcopy Create free account
hub / github.com/CreminiAI/skillpack / downloadMessageResource

Method downloadMessageResource

src/runtime/adapters/feishu.ts:447–483  ·  view source on GitHub ↗
(
    messageId: string,
    fileKey: string,
    type: FeishuSupportedResourceType,
  )

Source from the content-addressed store, hash-verified

445 filename: string,
446 ): string | undefined {
447 return detectMimeType(filename) || (resource.type === "image" ? "image/png" : undefined);
448 }
449
450 private async downloadMessageResource(
451 messageId: string,
452 fileKey: string,
453 type: FeishuSupportedResourceType,
454 ): Promise<Buffer> {
455 if (!this.channel) {
456 throw new Error("[Feishu] Channel not initialized");
457 }
458
459 const rawClient = this.channel.rawClient as
460 | {
461 im?: {
462 v1?: {
463 messageResource?: {
464 get?: (payload: {
465 path: { message_id: string; file_key: string };
466 params: { type: string };
467 }) => Promise<{ getReadableStream: () => NodeJS.ReadableStream }>;
468 };
469 };
470 };
471 }
472 | undefined;
473 const getMessageResource = rawClient?.im?.v1?.messageResource?.get;
474 if (getMessageResource) {
475 const response = await getMessageResource({
476 path: {
477 message_id: messageId,
478 file_key: fileKey,
479 },
480 params: { type },
481 });
482 return streamToBuffer(response.getReadableStream());
483 }
484
485 return this.channel.downloadResource(fileKey, type);
486 }

Callers 1

Calls 1

downloadResourceMethod · 0.45

Tested by

no test coverage detected