# 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](https://docs.imerit.net/sdk/sdk-documentation/..#project-ids) or retrieve it using the [`list_projects`](https://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/list_projects) function.
* **assets:** List\[str]
  * 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.&#x20;

<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](https://docs.imerit.net/core-concepts/attachments#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](https://docs.imerit.net/data/storages/importing-private-cloud-assets-gcp), this parameter is necessary. This is the ID of the bucket's integration, obtainable from [`get_storages`](https://docs.imerit.net/sdk/sdk-documentation/organization-level-sdk-functions/get_storages) 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`](https://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/get_batches) function, or create new ones using [`create_batch`](https://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/create_batch) 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.

### 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](https://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/upload_files), [upload\_files\_with\_asset\_builder](https://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/upload_files_with_asset_builder), [get\_storages](https://docs.imerit.net/sdk/sdk-documentation/organization-level-sdk-functions/get_storages)
{% endhint %}
