Skip to main content

Class: MediaParser

@sapphire/plugin-api.MediaParser

A media parser

since 1.3.0

Hierarchy

  • Piece

    MediaParser

Constructors

constructor

new MediaParser(context, options?)

Parameters

NameType
contextPieceContext
options?PieceOptions

Inherited from

Piece.constructor

Defined in

node_modules/@sapphire/pieces/dist/index.d.ts:452

Methods

accepts

accepts(route): boolean

Checks if a route accepts the media type from this parser.

since 1.3.0

Parameters

NameTypeDescription
routeRouteThe route to be checked.

Returns

boolean

Defined in

projects/plugins/packages/api/src/lib/structures/MediaParser.ts:24


contentStream

Protected contentStream(request): null | ApiRequest | Gunzip

Reads the content stream from a request, piping the data through a transformer stream.

since 1.3.0

Parameters

NameTypeDescription
requestApiRequestThe request to read the body from.

Returns

null | ApiRequest | Gunzip

Defined in

projects/plugins/packages/api/src/lib/structures/MediaParser.ts:63


readBuffer

Protected readBuffer(request): Promise<Buffer>

Reads the content body as a buffer, this is useful for parsing/reading binary data.

since 1.3.0

Parameters

NameTypeDescription
requestApiRequestThe request to read the body from.

Returns

Promise<Buffer>

Defined in

projects/plugins/packages/api/src/lib/structures/MediaParser.ts:48


readString

Protected readString(request): Promise<string>

Reads the content body as a string, this is useful for parsing/reading plain-text data.

since 1.3.0

Parameters

NameTypeDescription
requestApiRequestThe request to read the body from.

Returns

Promise<string>

Defined in

projects/plugins/packages/api/src/lib/structures/MediaParser.ts:33


run

Abstract run(request): unknown

Parses the body data from an API request.

since 1.3.0

Parameters

NameType
requestApiRequest

Returns

unknown

Defined in

projects/plugins/packages/api/src/lib/structures/MediaParser.ts:17