Options
All
  • Public
  • Public/Protected
  • All
Menu

Helpers that construct media SendFileMessageParams, SendImageMessageParams, SendGIFMessageParams, and SendHDVoiceMessageParams from browser {@link File} objects. On success, pass result.data to BaseChannel.sendMediaMessage.

Index

Functions

  • Builds file message send parameters from a local file (name, size, and inferred file type suffix).

    example
    const r = await Helper.createSendFileMessageParams(file);
    if (r.isOk) await channel.sendMediaMessage(r.data);

    Parameters

    • file: File

      The file to upload and send

    Returns Promise<NCResult<SendFileMessageParams>>

    A result containing SendFileMessageParams with file set, or an error if validation fails

  • Builds GIF message send parameters by loading the image to read width and height.

    example
    const r = await Helper.createSendGIFMessageParams(file);
    if (r.isOk) await channel.sendMediaMessage(r.data);

    Parameters

    • file: File

      The GIF file to upload and send

    Returns Promise<NCResult<SendGIFMessageParams>>

    A result containing SendGIFMessageParams with file set, or an error if the GIF cannot be loaded

  • Builds HD voice message send parameters by decoding audio to obtain duration, sample rate, and channel count (expects 16 kHz decode context).

    example
    const r = await Helper.createSendHDVoiceMessageParams(file);
    if (r.isOk) await channel.sendMediaMessage(r.data);

    Parameters

    • file: File

      The audio file to upload and send

    Returns Promise<NCResult<SendHDVoiceMessageParams>>

    A result containing SendHDVoiceMessageParams with file set, or an error if decoding fails

  • Builds image message send parameters by drawing a scaled thumbnail (max 160px) and JPEG base64 payload within size limits.

    example
    const r = await Helper.createSendImageMessageParams(file);
    if (r.isOk) await channel.sendMediaMessage(r.data);

    Parameters

    • file: File

      The image file to upload and send

    Returns Promise<NCResult<SendImageMessageParams>>

    A result containing SendImageMessageParams with file set, or an error if the image cannot be loaded

Variables

FileType: { IMAGE: 1; AUDIO: 2; VIDEO: 3; FILE: 4; SHORT_VIDEO: 5 } = ...

Type declaration

  • IMAGE: 1
  • AUDIO: 2
  • VIDEO: 3
  • FILE: 4
  • SHORT_VIDEO: 5

Type Aliases

FileType: typeof Helper.FileType[keyof typeof Helper.FileType]