# upload\_files\_cloud

`imerit_ango.sdk.SDK.`

## upload\_files\_cloud(project\_id, assets, storage\_id, batches, priority)

Import files in cloud storage to your project.

### Parameters

* **project\_id:** string
  * The unique identifier for the project. You can find the project ID in [the user interface](/sdk/sdk-documentation.md#project-ids) or retrieve it using the [`list_projects`](/sdk/sdk-documentation/project-level-sdk-functions/list_projects.md) function.
* **assets:** List\[dict]
  * A list of asset dictionaries in the \[{"data": \<URL>, "externalId": "\<external\_id>"}] format.
  * Assets uploaded with this method can also contain attachments, batches, metadata, and contextData.

<details>

<summary>Example</summary>

```json
public_file = [
    {
        "data": "https://angohub-public-assets.s3.eu-central-1.amazonaws.com/CzXTtJV.jpg",
        "externalId": "aws-public.png",
        "metadata": {
            "width": 1500,
            "height": 1800
        },
        "contextData": {
            "key1": "value1"
        },
        "batches": ["Batch 1", "Batch 2"]
        "attachments": [
            {'type': "IMAGE", 'value': "https://angohub-public-assets.s3.eu-central-1.amazonaws.com/CzXTtJV.jpg"},
            {'type': "TEXT", 'value': "An attachment."}]
    }
]
```

</details>

{% hint style="info" %}
For image and video attachments, you may provide links to assets in private buckets, provided that you've connected them to Ango Hub. More information on how to do so can be found on the [Attachments](/core-concepts/attachments.md#uploading-attachments-from-private-buckets) page.
{% endhint %}

For Markdown assets, you may directly include the Markdown file as plain text in the `data` field, like so:

```python
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK

load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')

ango_sdk = SDK(api_key)

markdown_text = """
<div style="margin:10px;display:flex;">
    <div style="width:50%">
        <div style="font-size:13px;font-weight:500;display:flex;">
            <div style="width:100px;color:gray">Hello World!</div>
        </div>
    </div>
</div>
"""

external_id = "100001.md"
batch_name = "Batch-1"

file_paths = []
file_paths.append({"data": markdown_text, "externalId": external_id, "batches": [batch_name]})

response = ango_sdk.upload_files_cloud(project_id=project_id, assets=file_paths)
```

{% hint style="info" %}
Batches you specify in the *assets* dictionary will override the batches you specify in the *batches* parameter of this function.
{% endhint %}

* **storage\_id:** string, *Optional, default None*
  * If importing files from a private bucket [previously integrated with Hub](/data/storages/importing-private-cloud-assets-gcp.md), this parameter is necessary. This is the ID of the bucket's integration, obtainable from [`get_storages`](/sdk/sdk-documentation/organization-level-sdk-functions/get_storages.md) function.
* **batches**: List\[str], *Optional, default None*
  * You may add the files being uploaded to one or multiple batches, by passing a list of batch IDs. You may obtain a list of batch IDs available in your project using [`get_batches`](/sdk/sdk-documentation/project-level-sdk-functions/get_batches.md) function, or create new ones using [`create_batch`](/sdk/sdk-documentation/project-level-sdk-functions/create_batch.md) function.
* **priority:** int, *Optional, default 0*
  * The new priority value to assign to the uploaded assets.
  * **Note:** The priority value must be between -1000 and 1000. Higher values indicate higher priority.

Returns:

* **output:** dict
  * A dictionary containing the result of the operation.
  * Including a `status` field indicating whether the request was successful and a `data` field containing the response payload with updated resources produced by the operation.

<details open>

<summary><strong>How to verify in Ango Hub?</strong></summary>

After successfully executing the `upload_files_cloud` function, you can validate the changes directly in Ango Hub.

Navigate to: **Projects → \[Your Project] → Asset**

* Ensure that all assets have been successfully imported and are visible in the project.

{% hint style="info" %}
Changes made via the SDK are reflected in Ango Hub in near real-time. If updates are not immediately visible, please refresh the page.
{% endhint %}

</details>

### Example

Importing a file from a public bucket, and assigning it to a batch:

{% tabs %}
{% tab title="python" %}

```python
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK

load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')

ango_sdk = SDK(api_key)

batch_id_list = ['<YOUR BATCH ID>']
public_file = [{"data": "https://storage.googleapis.com/a-public-bucket/file.png", 
                "externalId": "myExternalId.png"}]

ango_sdk.upload_files_cloud(
    project_id=project_id, 
    assets=public_file, 
    batches=batch_id_list
)
```

{% endtab %}

{% tab title="curl" %}

```bash
curl -X POST "https://imeritapi.ango.ai/v2/project/$PROJECT_ID/cloud?batches=%5B%22<YOUR_BATCH_ID>%22%5D" \
  -H "Content-Type: application/json" \
  -H "apikey: $ANGO_API_KEY" \
  -d '{
    "assets": [
      {
        "data": "https://storage.googleapis.com/a-public-bucket/file.png",
        "externalId": "myExternalId.png"
      }
    ],
    "uploadLocal": null,
    "priority": 0
  }'
```

{% endtab %}
{% endtabs %}

Importing a file from a private bucket, and assigning it to multiple batches:

{% tabs %}
{% tab title="python" %}

```python
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK

load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')

ango_sdk = SDK(api_key)

batch_id_list = ['<BATCH ID 1>', '<BATCH ID 2>']
storage_id = '<YOUR_STORAGE_ID>'

private_file = [{"data": "https://storage.googleapis.com/a-private-bucket/file.png",
                 "externalId": "myExternalId.png"}]

ango_sdk.upload_files_cloud(
    project_id=project_id,
    assets=private_file,
    batches=batch_id_list,
    storage_id=storage_id
)
```

{% endtab %}

{% tab title="curl" %}

```bash
curl -X POST "https://imeritapi.ango.ai/v2/project/$PROJECT_ID/cloud?batches=%5B%22<BATCH_ID_1>%22%2C%22<BATCH_ID_2>%22%5D" \
  -H "Content-Type: application/json" \
  -H "apikey: $ANGO_API_KEY" \
  -d '{
    "assets": [
      {
        "data": "https://storage.googleapis.com/a-private-bucket/file.png",
        "externalId": "myExternalId.png",
        "storage": "<YOUR_STORAGE_ID>"
      }
    ],
    "uploadLocal": null,
    "priority": 0
  }'
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**See also**

[upload\_files](/sdk/sdk-documentation/project-level-sdk-functions/upload_files.md), [upload\_files\_with\_asset\_builder](/sdk/sdk-documentation/project-level-sdk-functions/upload_files_with_asset_builder.md), [get\_storages](/sdk/sdk-documentation/organization-level-sdk-functions/get_storages.md)
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/upload_files_cloud.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
