Class File

Uploaded File

Constructors

  • Construct File

    Parameters

    • client: Client

      Client

    • file:
          | File
          | Pick<
              {
                  _id: string;
                  content_type: string;
                  deleted?: null
                  | boolean;
                  filename: string;
                  message_id?: null | string;
                  metadata:
                      | { type: "File" }
                      | { type: "Text" }
                      | {
                          animated?: null | boolean;
                          height: number;
                          thumbhash?: null | number[];
                          type: "Image";
                          width: number;
                      }
                      | { height: number; type: "Video"; width: number }
                      | { type: "Audio" };
                  object_id?: null | string;
                  reported?: null | boolean;
                  server_id?: null | string;
                  size: number;
                  tag: string;
                  user_id?: null | string;
              },
              "_id"
              | "tag"
              | "metadata",
          > & Partial<
              {
                  _id: string;
                  content_type: string;
                  deleted?: null
                  | boolean;
                  filename: string;
                  message_id?: null | string;
                  metadata:
                      | { type: "File" }
                      | { type: "Text" }
                      | {
                          animated?: null | boolean;
                          height: number;
                          thumbhash?: null | number[];
                          type: "Image";
                          width: number;
                      }
                      | { height: number; type: "Video"; width: number }
                      | { type: "Audio" };
                  object_id?: null | string;
                  reported?: null | boolean;
                  server_id?: null | string;
                  size: number;
                  tag: string;
                  user_id?: null | string;
              },
          >

      File

    Returns File

Properties

contentType?: string

Raw content type of this file

filename?: string

Original filename

id: string

File Id

metadata:
    | { type: "File" }
    | { type: "Text" }
    | {
        animated?: null | boolean;
        height: number;
        thumbhash?: null | number[];
        type: "Image";
        width: number;
    }
    | { height: number; type: "Video"; width: number }
    | { type: "Audio" }

Parsed metadata of the file

Type declaration

  • { type: "File" }
  • { type: "Text" }
  • {
        animated?: null | boolean;
        height: number;
        thumbhash?: null | number[];
        type: "Image";
        width: number;
    }
    • Optionalanimated?: null | boolean
    • height: number

      Format: uint

    • Optionalthumbhash?: null | number[]
    • type: "Image"
    • width: number

      Format: uint

  • { height: number; type: "Video"; width: number }
    • height: number

      Format: uint

    • type: "Video"
    • width: number

      Format: uint

  • { type: "Audio" }
size?: number

Size of the file (in bytes)

tag: string

File bucket

Accessors

Methods

  • Creates a URL to a given file with given options.

    Parameters

    • OptionalforceAnimation: boolean

      Returns GIF if applicable (for avatars/icons)

    Returns undefined | string

    Generated URL or nothing