Upload an element to the Cloud storage.

Parameters

content
Union[bytes, str]

The content of the element to be uploaded. This can be either a bytes object representing the file content or a string representing the file path.

mime
str

The MIME type of the element to be uploaded.

Returns

upload_details
Dict
required

A dictionary containing the object key and URL of the uploaded element.

Example

Code Example
from chainlit.client.cloud import chainlit_client

content = b"This is the content of the file"
mime = "text/plain"

upload_details = await chainlit_client.upload_element(content, mime)

if upload_details:
    object_key = upload_details["object_key"]
    url = upload_details["url"]
    print(f"Element uploaded with object key: {object_key}")
    print(f"Element URL: {url}")
else:
    print("Failed to upload element.")