Upload File

In this example we will upload a CSV file to the stored on the Kelvin Platform and receive the confirmation.

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

API cURL Example
1
2
3
4
5
6
7
curl -X "POST" \
"https://<url.kelvin.ai>/api/v4/filestorage/upload" \
-H "Authorization: Bearer <Your Current Token>" \
-H "Accept: application/json" \
-H "Content-Type: multipart/form-data" \
-F 'file=@/home/ubuntu/test_data.csv;type=text/plain" \
-F 'metadata={"customkey": "Custom metadata information"}'

The response will look like this;

API cURL Example Response
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
"file_id": "66fce65f-d43f-4424-89b8-e1dd01f9193b",
"file_name": "test_data.csv",
"file_size": 6,
"checksum": "66a045b452102c59d840ec097d59d9467e13a3f34f6494e539ffd32c1bb35f18",
"created": "2024-03-19T10:29:55.673471Z",
"source": "krn:user:demo@kelvin.ai",
"metadata": {
    "customkey": "Custom metadata information"
}
}
API Client (Python) Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
from kelvin.api.client import Client

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

# Upload file to filestore
response = client.filestorage.upload_file(
    file='/home/ubuntu/model_weights.h5', 
    metadata={"customkey": "Custom metadata information"}
)

print(response)

You will see the output like this;

API Client (Python) Example Response
1
file_id='d9a5a89b-7a72-4ff3-a7b6-eaefec4875ad' file_name='model_weights.h5' file_size=3066 checksum='1b342f992ac36da9018e84ba81623f3a862d351497bae2a129fe70df02e085ad' source='krn:user:demo@kelvin.ai' created=datetime.datetime(2024, 3, 24, 1, 51, 54, 699950, tzinfo=datetime.timezone.utc) metadata={"customkey": "Custom metadata information"}