upload_files

imerit_ango.sdk.SDK.

upload_files(project_id, file_paths, storage_id, batches)

Upload files to Ango Hub. A list of local file paths should be given as an input parameter.

Optionally, a custom externalID for the files may be given from within the file_paths parameter. (See examples below)

Parameters

  • project_id: string

  • file_paths: List[string]

    • A list containing absolute paths to files and, optionally, their contextData.

    • Example:

[
    {
        'data': '/Users/lorenzo/Desktop/Gassino,_arrival_of_tramway_auto_x2.jpg',
        'metadata': {
            "width": 1500,
            "height": 1200
        },
        'contextData': {
                'key1': 'value1'
        }
    }
]
  • storage_id: string, Optional, default None

    • This parameter has no function anymore and will be deprecated in the next version of the SDK.

  • batches: List[string], Optional, default None

    • You may assign the files you are uploading to one or more batches that exist in your project by providing their IDs here. You may create new batches with create_batch and you can get a list of batches with get_batches.

    • Example: ['0000000aa0a00a0000aaaa0a', '0000000aa0a00a0000aaaa0b']

Returns:

  • output: dict

Example

Importing two local files:

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)

file_paths = ["data/my_image_1.png", "data/my_image_2.png"]
ango_sdk.upload_files(project_id, file_paths)

Importing a file with a custom external ID:

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)

file_paths = [{"data": "data/my_image_1.png", "externalId": "custom!"}]
ango_sdk.upload_files(project_id, file_paths)

Last updated