upload_files_cloud
imerit_ango.sdk.SDK.
upload_files_cloud(project_id, assets, storage_id, batches)
Import files in cloud storage to Ango Hub. Check Importing Assets for more information.
Parameters
project_id: string
The unique identifier for the project. You can find the project ID in the user interface or retrieve it using the
list_projects
function.
assets: List[string]
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.
For Markdown assets, you may directly include the Markdown file as plain text in the data
field, like so:
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)
storage_id: string, Optional, default None
If importing files from a private bucket previously integrated with Hub, this parameter is necessary. This is the ID of the bucket's integration, obtainable from
get_storages
function.
batches: List[string], 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
function, or create new ones usingcreate_batch
function.
Returns:
output: dict
A dictionary containing the result of the operation.
Example
Importing a file from a public bucket, and assigning it to a batch:
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)
Importing a file from a private bucket, and assigning it to multiple batches:
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>' # Obtain with get_storages, mandatory when importing files from private buckets
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)
Last updated