Storing Files Using the API

Overview

Andi® offers skill writers the ability to access external files to perform various functions within a skill. Those files can be stored at the organization level or skill level in Blob storage provided by Andi®. The information the files contain can then be accessed through the storage powers when writing your skill. This article will cover how to use the API for file storage.

There is a file size limit of 100 MB. Prior to using the API, make sure you have a valid API key.

 

In this Article

 

Organization Level Storage

Files should be stored at the organization level when it is expected that the information the files contain contain will be utilized by multiple skills. These files will not be visible in the Skills Manager.

Upload a File

Using your API program environment, create a POST request to the following URL:

https://api-andi.precisionlender.com/storage/files/{filename}

where the Path

  • filename = the name and file type you will give the file and will be used to identify the file in the database. This does not have to be the same as the name of the actual file. Anytime the path with that specific filename is used, the existing file will be overridden.

with the required Headers

Key Value Notes
Authorization Bearer [API_KEY] The API_KEY value is the API key that was created

The key will indicate the organization the file belongs to and that the requester has the appropriate permission to upload the file to the organization.

Then enter the Body with the following:

  • form-data type
Key Value Notes
file any This will be the file that you upload. Preferred formats are .csv or .json.

Then send the request.

Example Request

curl -X POST \
  https://api-andi.precisionlender.com/storage/files/test.csv \
  -H 'authorization: Bearer [API_KEY]' \
  -H 'cache-control: no-cache' \
  -F =@test.csv

A successful upload will return the Resource Path for where the file is located.

{
    "resourcePath": "/orgs/{organization_id}/storage/test.csv",
    "status": "ok"
}

where the Path

  • organization_id = your organization's ID that will be returned in the response

 

Retrieve an Uploaded File

Using your API program environment, create a GET request to the following URL:

https://api-andi.precisionlender.com/storage/files/{filename}

where the Path

  • filename = the name given to the file in order to identify the file in the database.

with the required Header

Key Value Notes
Authorization Bearer [API_KEY] The API_KEY value is the API key that was created

The key will indicate that the requester belongs to the organization and has the appropriate permission to retrieve the file from that organization.

Then send the request.

Example Request

curl -X GET \
  https://api-andi.precisionlender.com/storage/files/test.csv \
  -H 'authorization: Bearer [API_KEY]' \
  -H 'cache-control: no-cache' \

A successful request will return the data from the file. 

 

A file cannot be deleted via API from this level at this time.

 

Skill Level Storage

Files should be stored at the skill level when they will only be used by a single skill. They can be uploaded to this level via the API or via the Storage section of the skill page in the Skill Manager. If uploaded via API, the file will also appear in the Storage section of the skill page.

Upload a File

Using your API program environment, create a POST request to the following URL:

https://api-andi.precisionlender.com/storage/skills/{skillPackageId}/files/{filename} 

where the Path

  • skillPackageId = the id that identifies a skill.
    • This can be obtained from the skill's page URL in the Andi Skills Manager. In the address bar, after https://.......skillsPackage/, there will be a GUID, which is the skill package id.

skillPackageId.png

  • filename = the name and file type you will give the file and will be used to identify the file in the database. This does not have to be the same as the name of the actual file. Anytime the path with that specific filename is used, the existing file will be overridden.

with the required Headers

Key Value Notes
Authorization Bearer [API_KEY] The API_KEY value is the API key that was created

The key will indicate the organization the file belongs to and that the requester has the appropriate permission to upload the file to the organization.

Then enter the Body with the following:

  • form-data type
Key Value Notes
file any This will be the file that you upload. Preferred formats are .csv or .json.

Then send the request.

Example Request

curl -X POST \
https://api-andi.precisionlender.com/storage/skills/{skillPackageId}/files/test.csv \
-H 'authorization: Bearer [API_KEY]' \
-H 'cache-control: no-cache' \
-F =@test.csv

A successful upload will return the Resource Path for where the file is located.

{
"resourcePath": "/orgs/{organization_id}/skills/published/{skillPackageId}/storage/test.csv",
"status": "ok"
}

where the Path

  • organization_id = your organization's ID that will be returned in the response.
  • skillPackageId = the id that identifies the skill the file was uploaded to.

 

Retrieve an Uploaded File

Using your API program environment, create a GET request to the following URL:

https://api-andi.precisionlender.com/storage/skills/{skillPackageId}/files/{filename} 

where the Path

  • skillPackageId = the id that identifies a skill.
    • This can be obtained from the skill's page URL in the Andi Skills Manager. In the address bar, after https://.......skillsPackage/, there will be a GUID, which is the skill package id.

skillPackageId.png

  • filename = the name given to the file in order to identify the file in the database.

with the required Header

Key Value Notes
Authorization Bearer [API_KEY] The API_KEY value is the API key that was created

The key will indicate that the requester belongs to the organization and has the appropriate permission to retrieve the file from the skill for that organization.

Then send the request.

Example Request

curl -X GET \
https://api-andi.precisionlender.com/storage/skills/{skillPackageId}/files/test.csv \
-H 'authorization: Bearer [API_KEY]' \
-H 'cache-control: no-cache' \

A successful request will return the data from the file.

 

Delete an Uploaded File

You can delete the file(s) from the Storage section of the skill's page in the Skill Manager.

 

Was this article helpful?
0 out of 0 found this helpful