telegramsjs
    Preparing search index...

    Class MediaData

    A class for handling media data and preparing configuration for API requests.

    Index

    Constructors

    Properties

    extensions: Record<string, string>

    Mapping of media type extensions.

    formDataJsonFields: string[]

    Fields in the form data that should be JSON-encoded.

    sourceParametersMedia: string[]

    Parameters that can contain media data.

    Methods

    • Attaches media to the form data.

      Parameters

      • form: MultipartStream

        The form to which the media should be attached.

      • media: string | Buffer<ArrayBufferLike> | ReadStream

        The media to attach, can be a string path, buffer, or read stream.

      • options: { filename?: string; id: string }

        The options of the form field.

      Returns Promise<void>

    • Attaches a value to the form data.

      Parameters

      • form: MultipartStream

        The form to which the value should be attached.

      • id: string

        The name of the form field.

      • value: any

        The value to attach to the form.

      • agent: boolean | Agent | ((parsedUrl: URL) => boolean | Agent | undefined) | undefined

        The agent to use for fetching external resources.

      Returns Promise<void>

    • Builds the configuration for a form-data request.

      Parameters

      • apiPayload: Record<string, any>

        The data to be sent in the request.

      • OptionalrequestOptions: RequestInit

        Additional options for the request.

      Returns Promise<IApiConfig>

      The configuration for the request.

    • Builds the configuration for a JSON request.

      Parameters

      • payload: Record<string, any>

        The data to be sent in the request.

      • OptionalrequestOptions: RequestInit

        Additional options for the request.

      Returns IApiConfig

      The configuration for the request.

    • Checks if the payload contains media data.

      Parameters

      • payload: Record<string, any>

        The data to check.

      Returns boolean

      true if media is found, otherwise false.

    • Checks if the given value is a media-related object. This function determines if the provided value is an object associated with media data types such as Buffer, ArrayBuffer, Blob, FormData, Uint8Array, or DataView.

      Parameters

      • value: any

        The value to check.

      Returns boolean

      true if the value is a media-related object; otherwise, false.