@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
86 lines (51 loc) • 1.7 kB
Markdown
---
lang: en
title: 'API docs: openapi-v3.requestbody.file'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/openapi-v3
permalink: /doc/en/lb4/apidocs.openapi-v3.requestbody.file.html
---
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/openapi-v3](./openapi-v3.md) > [requestBody](./openapi-v3.requestbody.md) > [file](./openapi-v3.requestbody.file.md)
## 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](https://swagger.io/docs/specification/describing-request-body/file-upload)
**Signature:**
```typescript
file: (properties?: {
description?: string;
required?: boolean;
}) => (target: object, member: string, index: number) => void
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td markdown="1">
properties
</td><td markdown="1">
{ description?: string; required?: boolean; }
</td><td markdown="1">
_(Optional)_ Optional description and required flag
</td></tr>
</tbody></table>
**Returns:**
(target: object, member: string, index: number) => void
## Example
import {<!-- -->Request<!-- -->} from '<!-- -->@<!-- -->loopback/rest';
```ts
class MyController {
@post('/pictures')
upload(
@requestBody.file()
request: Request,
) {
// ...
}
}
```