> ## Documentation Index
> Fetch the complete documentation index at: https://docs.squarecloud.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Blob Chunked Upload Complete

> Questa documentazione fornisce una panoramica completa dell'endpoint PATCH /v1/objects/chunked dell'API Blob di SquareCloud.

<ParamField header="Authorization" type="string" placeholder="API Key" required>
  La chiave API del tuo account. Puoi trovarla nelle [impostazioni del tuo account](https://squarecloud.app/it/account/security).
</ParamField>

Chunked Complete sigilla un caricamento aperto con [Chunked Init](/it/blob-reference/endpoint/chunked-init): le parti memorizzate vengono assemblate nell'oggetto finale, che diventa disponibile al suo URL pubblico. Non invii **né ETag né elenco delle parti**, solo il token `upload`; l'elenco delle parti viene riletto dallo storage, che è già l'autorità su quali parti sono arrivate.

Due modalità di errore lasciano deliberatamente il caricamento **aperto**, così puoi risolvere il problema e ritentare la `PATCH` invece di ricaricare fino a 1 GiB: `STORAGE_QUOTA_EXCEEDED` (libera spazio, poi riprova) e `CHUNK_TOO_SMALL` (reinvia le parti problematiche, poi riprova). `FILE_TOO_SMALL` e `FILE_TOO_LARGE` invece annullano il caricamento.

Il limite di frequenza è di 5 completamenti ogni 10 secondi, così diversi caricamenti paralleli possono terminare nello stesso momento.

<ParamField body="upload" type="string" placeholder="Upload token" required>
  Il token `upload` opaco restituito da Chunked Init.

  ```json theme={null}
  { "upload": "UPLOAD_TOKEN" }
  ```
</ParamField>

### Risposta

<ResponseField name="status" type="string">
  Indica se la chiamata è andata a buon fine. "success" se riuscita, "error" in caso contrario.
</ResponseField>

<ResponseField name="response" type="object">
  <Expandable title="Toggle object">
    <ResponseField name="id" type="string">
      L'ID (chiave) dell'oggetto memorizzato.
    </ResponseField>

    <ResponseField name="size" type="number">
      La dimensione totale dell'oggetto assemblato, in byte.
    </ResponseField>

    <ResponseField name="parts" type="number">
      Il numero di parti da cui l'oggetto è stato assemblato.
    </ResponseField>

    <ResponseField name="url" type="string">
      L'URL pubblico CDN dell'oggetto.
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request PATCH \
    --url 'https://blob.squarecloud.app/v1/objects/chunked' \
    --header 'Authorization: YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{ "upload": "UPLOAD_TOKEN" }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://blob.squarecloud.app/v1/objects/chunked', {
    method: 'PATCH',
    headers: {
      Authorization: 'YOUR_API_KEY',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ upload: uploadToken }),
  });
  ```

  ```python Python theme={null}
  import requests

  response = requests.patch(
      'https://blob.squarecloud.app/v1/objects/chunked',
      headers={'Authorization': 'YOUR_API_KEY'},
      json={'upload': upload_token},
  )
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "status": "success",
    "response": {
      "id": "3155597145698959364/myfile-ex30.fastq.gz",
      "size": 734003200,
      "parts": 22,
      "url": "https://public-blob.squarecloud.dev/3155597145698959364/myfile-ex30.fastq.gz"
    }
  }
  ```
</ResponseExample>

### Risoluzione dei problemi

<Tabs>
  <Tab title="Status Code 400">
    ### Relativi al caricamento

    <CodeGroup>
      ```json INVALID_UPLOAD_TOKEN theme={null}
      // The upload token is missing, malformed, or does not belong to your account.
      {
          "status": "error",
          "code": "INVALID_UPLOAD_TOKEN"
      }
      ```

      ```json NO_CHUNKS_UPLOADED theme={null}
      // The upload has no stored chunks to assemble.
      {
          "status": "error",
          "code": "NO_CHUNKS_UPLOADED"
      }
      ```

      ```json CHUNK_TOO_SMALL theme={null}
      // A chunk other than the last is below 5 MB. The upload stays open:
      // re-send the offending parts, then retry the PATCH.
      {
          "status": "error",
          "code": "CHUNK_TOO_SMALL"
      }
      ```

      ```json FILE_TOO_SMALL theme={null}
      // The assembled object is below 512 bytes. The upload is aborted.
      {
          "status": "error",
          "code": "FILE_TOO_SMALL"
      }
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Status Code 401">
    ### Non autorizzato

    <CodeGroup>
      ```json ACCESS_DENIED theme={null}
      // The API key is missing or invalid. Set a valid key in the Authorization header.
      {
          "status": "error",
          "code": "ACCESS_DENIED"
      }
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Status Code 403">
    ### Quota di archiviazione superata

    <CodeGroup>
      ```json STORAGE_QUOTA_EXCEEDED theme={null}
      // The account filled up while the parts were uploading. The upload is
      // LEFT OPEN: free space (or upgrade) and retry the PATCH, or abort it
      // with DELETE /v1/objects/chunked.
      {
          "status": "error",
          "code": "STORAGE_QUOTA_EXCEEDED"
      }
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Status Code 404">
    ### Non trovato

    <CodeGroup>
      ```json UPLOAD_NOT_FOUND theme={null}
      // The upload was already completed, aborted, or expired.
      {
          "status": "error",
          "code": "UPLOAD_NOT_FOUND"
      }
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Status Code 413">
    ### Payload troppo grande

    <CodeGroup>
      ```json FILE_TOO_LARGE theme={null}
      // The assembled object exceeds 1 GiB. The upload is aborted.
      {
          "status": "error",
          "code": "FILE_TOO_LARGE"
      }
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Status Code 429">
    ### Frequenza limitata

    <CodeGroup>
      ```json RATE_LIMITED theme={null}
      // Complete rate limit reached (5 requests per 10s window, blocked for 10s).
      {
          "status": "error",
          "code": "RATE_LIMITED"
      }
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Status Code 500">
    ### Caricamento fallito

    <CodeGroup>
      ```json UPLOAD_FAILED theme={null}
      // Failed to assemble or register the object. If the message says to start
      // a new upload, the uploadId was consumed: open a new upload and send the
      // file again. Otherwise, retry the PATCH.
      {
          "status": "error",
          "code": "UPLOAD_FAILED"
      }
      ```
    </CodeGroup>
  </Tab>
</Tabs>
