> ## 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 Part

> Questa documentazione fornisce una panoramica completa dell'endpoint PUT /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 Part invia un chunk di un caricamento aperto con [Chunked Init](/it/blob-reference/endpoint/chunked-init). Il body è costituito dai **byte grezzi** del chunk, non da multipart/form-data. I numeri di parte vanno da 1 a `max_parts` (205) e possono essere inviati in **qualsiasi ordine**; una parte fallita può semplicemente essere reinviata con lo stesso numero, e il reinvio è sicuro perché le parti sono idempotenti.

Ogni chunk tranne l'ultimo deve essere compreso tra **5 MB e 32 MB**; l'ultimo può essere più piccolo. Invia al massimo **6 parti in parallelo**: una settima parte in volo restituisce `TOO_MANY_CONCURRENT_CHUNKS`; in tal caso attendi che una finisca e ritenta quella parte. Con 6 parti in volo, chunk da 16 MB sono un buon default per un browser.

Questa route è esente dal budget API dell'intero account (`plan.rate`), quindi un caricamento lungo non può esaurire la tua quota API per il resto della piattaforma. Il suo limitatore dedicato consente 60 parti ogni 10 secondi, con blocco di 10 secondi oltre quel limite.

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

<ParamField query="part" type="number" placeholder="1..205" required>
  Il numero della parte, da 1 a 205. Le parti possono essere inviate in qualsiasi ordine.
</ParamField>

<ParamField body="body" type="binary" required>
  I byte grezzi del chunk (`Content-Type: application/octet-stream`). **Non** multipart/form-data.
</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="part" type="number">
      Il numero della parte memorizzata.
    </ResponseField>

    <ResponseField name="size" type="number">
      La dimensione del chunk memorizzato, in byte.
    </ResponseField>

    <ResponseField name="etag" type="string">
      L'ETag di storage della parte. Solo informativo: il completamento rilegge l'elenco delle parti dallo storage, quindi non lo rinvii mai.
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request PUT \
    --url 'https://blob.squarecloud.app/v1/objects/chunked?upload=UPLOAD_TOKEN&part=1' \
    --header 'Authorization: YOUR_API_KEY' \
    --header 'Content-Type: application/octet-stream' \
    --data-binary '@./chunk-1.bin'
  ```

  ```javascript JavaScript theme={null}
  const chunk = file.slice(0, 16 * 1024 * 1024); // first 16 MB

  const params = new URLSearchParams({ upload: uploadToken, part: '1' });

  const response = await fetch(`https://blob.squarecloud.app/v1/objects/chunked?${params}`, {
    method: 'PUT',
    headers: {
      Authorization: 'YOUR_API_KEY',
      'Content-Type': 'application/octet-stream',
    },
    body: chunk,
  });
  ```

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

  with open('./bigfile.bin', 'rb') as f:
      chunk = f.read(16 * 1024 * 1024)

  response = requests.put(
      'https://blob.squarecloud.app/v1/objects/chunked',
      headers={'Authorization': 'YOUR_API_KEY', 'Content-Type': 'application/octet-stream'},
      params={'upload': upload_token, 'part': 1},
      data=chunk,
  )
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "status": "success",
    "response": {
      "part": 1,
      "size": 16777216,
      "etag": "\"9bb58f26192e4ba00f01e2e7b136bbd8\""
    }
  }
  ```
</ResponseExample>

### Risoluzione dei problemi

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

    <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 INVALID_CHUNK_PART theme={null}
      // The part number must be an integer between 1 and 205.
      {
          "status": "error",
          "code": "INVALID_CHUNK_PART"
      }
      ```

      ```json EMPTY_CHUNK theme={null}
      // The chunk body was empty.
      {
          "status": "error",
          "code": "EMPTY_CHUNK"
      }
      ```
    </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"
      }
      ```

      ```json PERMISSION_DENIED theme={null}
      // The account has no active paid plan. Uploading to Blob Storage requires a paid plan.
      {
          "status": "error",
          "code": "PERMISSION_DENIED"
      }
      ```
    </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 CHUNK_TOO_LARGE theme={null}
      // Each chunk accepts up to 32 MB.
      {
          "status": "error",
          "code": "CHUNK_TOO_LARGE"
      }
      ```
    </CodeGroup>
  </Tab>

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

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

      ```json TOO_MANY_CONCURRENT_CHUNKS theme={null}
      // At most 6 chunks may be in flight at a time. Wait for one to finish, then retry this part.
      {
          "status": "error",
          "code": "TOO_MANY_CONCURRENT_CHUNKS"
      }
      ```
    </CodeGroup>
  </Tab>

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

    <CodeGroup>
      ```json UPLOAD_FAILED theme={null}
      // Failed to upload the chunk. Retry this part.
      {
          "status": "error",
          "code": "UPLOAD_FAILED"
      }
      ```
    </CodeGroup>
  </Tab>
</Tabs>
