Skip to content

Class: MediaEndpoint ​

Defined in: endpoints/media.ts:6

Constructors ​

Constructor ​

ts
new MediaEndpoint(client): MediaEndpoint;

Defined in: endpoints/media.ts:7

Parameters ​

ParameterType
clientRESTClient

Returns ​

MediaEndpoint

Methods ​

downloadAttachment() ​

ts
downloadAttachment(url, signal?): Promise<Blob>;

Defined in: endpoints/media.ts:10

fetch private bytes with the current session, never put credentials in a url.

Parameters ​

ParameterType
urlstring
signal?AbortSignal

Returns ​

Promise<Blob>


uploadMedia() ​

ts
uploadMedia(params): Promise<IUploadMediaResponse>;

Defined in: endpoints/media.ts:16

Parameters ​

ParameterType
params{ fileBase64: string; filename: string; mediaType: IMediaType; }
params.fileBase64string
params.filenamestring
params.mediaTypeIMediaType

Returns ​

Promise<IUploadMediaResponse>


uploadMediaFile() ​

ts
uploadMediaFile(params): Promise<IUploadMediaResponse>;

Defined in: endpoints/media.ts:34

Upload bytes directly so large files never increase the JSON request limit.

crop keeps only that part of a profile picture, banner, background or badge picture; the server crops it, so animations survive.

Parameters ​

ParameterTypeDescription
params{ channelId?: number; crop?: ICropRect; file: Blob; filename: string; mediaType: IMediaType; }-
params.channelId?numberRequired for bot attachments; binds the upload to an allowed channel.
params.crop?ICropRect-
params.fileBlob-
params.filenamestring-
params.mediaTypeIMediaType-

Returns ​

Promise<IUploadMediaResponse>

Released under the GNU Affero General Public License v3.0.