> For the complete documentation index, see [llms.txt](https://kinesis-school-of-programming.gitbook.io/nestjs-unleashed/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinesis-school-of-programming.gitbook.io/nestjs-unleashed/extra-module-4-file-management/basic-file-route.md).

# Basic file route

The first steps for managing files.

Let's go back to the <mark style="color:blue;">`ProductsController`</mark> and add a new route, responsible for uploading an <mark style="color:blue;">`image`</mark> of a product. The files section has some nuances, so let's proceed slowly so that we don't get lost in the process. We'll begin by creating a very simple route, and gradually add to its structure.

```typescript
@Post(':id/image')
uploadImage() {
  return 'Uploaded an image';
}
```

We now have a route for this purpose. Let's then allow a file upload. To extract files in the route, the process is a bit similar to extracting path/query params. First, we should use the <mark style="color:blue;">`FileInterceptor`</mark>, which has, as parameter, the name of the field that contains the file.

```typescript
@UseInterceptors(FileInterceptor('file'))
```

Then pass, as argument to the route handler, the decorator <mark style="color:blue;">`@UploadedFile()`</mark>, which will actually contain a reference to the file. We also use the types package installed previously to type the file.

```typescript
@UploadedFile() file: Express.Multer.File
```

We may also create a **type alias** for this in <mark style="color:purple;">src</mark>/<mark style="color:purple;">files</mark>/<mark style="color:purple;">types</mark>/<mark style="color:purple;">file.types</mark>.

```typescript
export type File = Express.Multer.File;
```

And we're done. We may even return the file to see its fields, obtaining the following result:

```typescript
@UseInterceptors(FileInterceptor('file'))
@Post(':id/image)
uploadImage(@UploadedFile() file: File) {
  return file;
}
```

<mark style="color:green;">**Commit**</mark> - Using multer to extract files
