# CompleteMultipartUpload

The request completes the composite download.

When receiving an Object Storage request:

* Assembles the final object from the parts obtained during the download process in the order of their numbers
* Removes the download ID so that all subsequent requests with the download ID will return an error `NoSuchUpload`.

When the download is complete, the client must provide a list of the parts that he sent. The description of each part should contain `ETag`, which the client receives in response to each downloaded part. See section [The UploadPart Method](https://docs.coldstack.io/http-api-compatible-with-amazon-s3/api-reference/multipart-upload/uploadpart) .

Depending on the size of the object and the number of parts, the operation may take several minutes.

If the request fails, then the client application should be ready to retry the request.

### Request <a href="#request" id="request"></a>

```
POST /{bucket}/{key}?uploadId=UploadId HTTP/1.1
```

#### Path parameters <a href="#path-parameters" id="path-parameters"></a>

| Parameter | Description  |
| --------- | ------------ |
| `bucket`  | Bucket name. |
| `key`     | Object key.  |

#### Query parameters <a href="#request-parameters" id="request-parameters"></a>

| Parameter  | Description                                                                                                                                                                    |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `uploadId` | The composite load ID that ColdStack returned upon [initialization](https://docs.coldstack.io/http-api-compatible-with-amazon-s3/api-reference/multipart-upload/startupload) . |

#### Headings <a href="#request-headers" id="request-headers"></a>

Use the required [common headers](https://docs.coldstack.io/http-api-compatible-with-amazon-s3/api-reference/common-request-headers) in the request .

#### Data schema <a href="#request-scheme" id="request-scheme"></a>

The list of parts of a composite download is sent as an XML file in the following format:

```
<CompleteMultipartUpload>
  <Part>
    <PartNumber>PartNumber</PartNumber>
    <ETag>ETag</ETag>
  </Part>
  ...
</CompleteMultipartUpload>
```

| Tag                       | Description                                                                                                                                                                                |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `CompleteMultipartUpload` | <p>Request data.<br><br>Path: <code>/CompleteMultipartUpload</code>.</p>                                                                                                                   |
| `Part`                    | <p>Data about the loaded part of the object.<br><br>Path: <code>/CompleteMultipartUpload/Part</code>.</p>                                                                                  |
| `PartNumber`              | <p>Part number.<br><br>A unique identifier that identifies the position of the part among other parts in the load.<br><br>Path: <code>/CompleteMultipartUpload/Part/PartNumber</code>.</p> |
| `ETag`                    | <p>The identifier that the client received from ColdStack in response to downloading the part.<br><br>Path: <code>/CompleteMultipartUpload/Part/ETag</code>.</p>                           |

### Answer <a href="#response" id="response"></a>

#### Headings <a href="#response-headers" id="response-headers"></a>

The response can only contain [general headers](https://docs.coldstack.io/http-api-compatible-with-amazon-s3/api-reference/common-response-headers) .

#### Answer codes <a href="#response-codes" id="response-codes"></a>

For a list of possible answers, see the [Answers](https://docs.coldstack.io/http-api-compatible-with-amazon-s3/api-reference/answers) section .

Additionally, ColdStack may return the errors described in the table below.

| Mistake            | Description                                                                                                                                                                    | HTTP code       |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------- |
| `NoSuchUpload`     | The specified download does not exist. The download ID may be incorrect, or the download may have completed or been deleted.                                                   | 404 Not Found   |
| `InvalidPart`      | <p>Some of the specified parts have not been found.<br><br>Possible causes:<br>- Parts not loaded.<br>- The transmitted one <code>ETag</code>does not match the saved one.</p> | 400 Bad Request |
| `InvalidPartOrder` | <p>The list of parts is not transmitted in ascending order.<br><br>The list should be sorted in ascending order by part number.</p>                                            | 400 Bad Request |

The successful response contains additional data in XML format, the schema of which is described below.

#### Data schema <a href="#request-scheme1" id="request-scheme1"></a>

```
<CompleteMultipartUploadResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
  <Location>http://Example-Bucket.s3.coldstack.io/Example-Object</Location>
  <Bucket>Example-Bucket</Bucket>
  <Key>Example-Object</Key>
  <ETag>"3858f62230ac3c915f300c664312c11f-9"</ETag>
</CompleteMultipartUploadResult>
```

| Tag                             | Description                                                                                                                      |
| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `CompleteMultipartUploadResult` | <p>Response data.<br><br>Path: <code>/CompleteMultipartUploadResult</code>.</p>                                                  |
| `Location`                      | <p>The URI of the resulting download of the object.<br><br>Path: <code>/CompleteMultipartUploadResult/Location</code>.</p>       |
| `Bucket`                        | <p>The name of the bucket in which the object is located.<br><br>Path: <code>/CompleteMultipartUploadResult/Bucket</code>.</p>   |
| `Key`                           | <p>The key of the created object.<br><br>Path: <code>/CompleteMultipartUploadResult/Key</code>.</p>                              |
| `ETag`                          | <p>The hash of the object.<br><br>ETag may or may not be MD5.<br><br>Path: <code>/CompleteMultipartUploadResult/ETag</code>.</p> |
