---
search:
  tags:
    - Prodotti
    - POST
seo:
  description: >-
    Carica un’immagine del prodotto (campo multipart file) e imposta imageUrl.
    Sostituisce l’immagine precedente. Richiede una chiave Write. Max. 10 MiB…
sidebar:
  label: Carica immagine prodotto
  badge: POST
title: Carica immagine prodotto
type: openapi-operation
---
Carica un’immagine del prodotto (campo multipart `file`) e imposta `imageUrl`. Sostituisce l’immagine precedente. Richiede una chiave Write. Max. 10 MiB (10.485.760 byte). Il tipo è preso dall’header `Content-Type` della parte: jpeg, png, webp o gif.

`POST /products/{productId}/image`

**Request body** (`multipart/form-data`, required)

- `file` (any, required) — File immagine (jpeg, png, webp o gif), max. 10 MiB.

Request body example:

```json
{
  "file": null
}
```

**Responses**

- `200` — Caricato
- `400` — Parametri o body non validi.
- `403` — Chiave API mancante, sconosciuta o inattiva, oppure chiave Read su un’operazione di scrittura.
- `404` — Nessun elemento con questo id.
- `413` — File troppo grande

Response example, 200:

```json
{
  "data": {
    "url": "https://firebasestorage.googleapis.com/v0/b/example/o/instance%2Forg%2Fproducts%2Fprod%2Fphoto.jpg?alt=media&token=abc",
    "imageUrl": "https://firebasestorage.googleapis.com/v0/b/example/o/instance%2Forg%2Fproducts%2Fprod%2Fphoto.jpg?alt=media&token=abc"
  }
}
```

Response example, 400:

```json
{
  "statusCode": 400,
  "message": "Validation failed for Field: name, Error: Required",
  "timestamp": "2024-04-20T12:00:00.000Z",
  "path": "/api/v1/suppliers"
}
```

Response example, 403:

```json
{
  "statusCode": 403,
  "message": "Unknown Error",
  "timestamp": "2024-04-20T12:00:00.000Z",
  "path": "/api/v1/products"
}
```
