---
lang: en
title: 'API docs: openapi-v3.response.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.response.file.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/openapi-v3](./openapi-v3.md) &gt; [response](./openapi-v3.response.md) &gt; [file](./openapi-v3.response.file.md)

## response.file() function

Decorate the response as a file

**Signature:**

```typescript
file: (...mediaTypes: string[]) => MethodDecorator
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td markdown="1">

mediaTypes


</td><td markdown="1">

string\[\]


</td><td markdown="1">

A list of media types for the file response. It's default to `['application/octet-stream']`<!-- -->.


</td></tr>
</tbody></table>

**Returns:**

MethodDecorator

## Example


```ts
import {oas, get, param} from '@loopback/openapi-v3';
import {RestBindings, Response} from '@loopback/rest';

class MyController {
  @get('/files/{filename}')
  @oas.response.file('image/jpeg', 'image/png')
  download(
    @param.path.string('filename') fileName: string,
    @inject(RestBindings.Http.RESPONSE) response: Response,
  ) {
    // use response.download(...);
  }
}
```


