Page Contents

Home > @loopback/openapi-v3 > requestBody > file

requestBody.file() function

Define a requestBody of file type. This is used to support multipart/form-data based file upload. Use @requestBody for other content types.

OpenAPI file upload

Signature:

file: (properties?: {
        description?: string;
        required?: boolean;
    }) => (target: object, member: string, index: number) => void

Parameters

Parameter Type Description
properties { description?: string; required?: boolean; } (Optional) Optional description and required flag

Returns:

(target: object, member: string, index: number) => void

Example

import {Request} from ‘@loopback/rest’;

class MyController {
  @post('/pictures')
  upload(
    @requestBody.file()
    request: Request,
  ) {
    // ...
  }
}