Download File

In this example we will download a file from the storage on the Kelvin Platform.

There are also options to add custom metadata to help classify and filter file listings.

curl -X "GET" \
"https://<url.kelvin.ai>/api/v4/filestorage/ef636192-e7eb-4f15-82df-2880df880f65/download" \
-H "Authorization: Bearer <Your Current Token>" \
-H "Accept: application/octet-stream'

The response code will be 200 or an error code from 4XX and the file itself.

This will save the file locally.

from kelvin.api.client import Client

# Login
client = Client(config={"url": "https://<url.kelvin.ai>", "username": "<your_username>"})
client.login(password="<your_password>")

# Download File from Filestorage
 with open("output.csv", "w") as file:
        writer = csv.writer(file)
        for byte in client.filestorage.download_file(file_id="0adecb9e-1a50-4459-946d-cb73fc7efe98"):
            decoded_str = byte.decode("utf-8")
            rows = decoded_str.split("\n")
            for row in rows:
                writer.writerow(row.split(","))