Skip to main content

Class: abstract MediaParser<Options>

A media parser

Since

1.3.0

Extends

  • Piece<Options, "mediaParsers">

Type parameters

Type parameterValue
Options extends OptionsOptions

Constructors

new MediaParser()

new MediaParser<Options>(context: LoaderContext, options: Options): MediaParser<Options>

Parameters

ParameterType
contextLoaderContext
optionsOptions

Returns

MediaParser<Options>

Overrides

Piece<Options, 'mediaParsers'>.constructor

Source

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

Methods

accepts()

accepts(route: Route <RouteOptions>): boolean

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

Parameters

ParameterTypeDescription
routeRoute <RouteOptions>The route to be checked.

Returns

boolean

Since

1.3.0

Source

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


contentStream()

protected contentStream(request: ApiRequest): null | Gunzip | ApiRequest

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

Parameters

ParameterTypeDescription
requestApiRequestThe request to read the body from.

Returns

null | Gunzip | ApiRequest

Since

1.3.0

Source

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


readBuffer()

protected readBuffer(request: ApiRequest): Promise<Buffer>

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

Parameters

ParameterTypeDescription
requestApiRequestThe request to read the body from.

Returns

Promise<Buffer>

Since

1.3.0

Source

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


readString()

protected readString(request: ApiRequest): Promise<string>

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

Parameters

ParameterTypeDescription
requestApiRequestThe request to read the body from.

Returns

Promise<string>

Since

1.3.0

Source

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


run()

abstract run(request: ApiRequest): unknown

Parses the body data from an API request.

Parameters

ParameterType
requestApiRequest

Returns

unknown

Since

1.3.0

Source

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