Storage API
File operations (upload, download, etc.) can be performed on Avgidea Storage via the API.
Common parameters
% curl -X POST -H 'content-type: application/json' -d '{"accesskey":"<accesskey>", "secret":"secretkey", "component":"storage", "action":"<action>" ... }' https://<endpoint url>
Parameters
accesskey : Access key
secet:Secret key
component : storage
action : action to execute
endpoint url : URL to send API requests
% curl -X POST -d "{\"accesskey\":\"<accesskey>\", \"secret\":\"<secretkey>\", \"component\":\"function\", \"action\":\"<action>\" ...}" https://<endpoint url>
Note :
When using curl commands under Windows, use only double quotes and escape within JSON data, as in the example at left.
Uploading an object
Uploading a file requires the following two steps
Generate a reference for upload
Upload the file on the local environment
1. Generate references for upload
% curl -X POST -H 'content-type: application/json' -d '{"accesskey":"<accesskey>", "secret":"secretkey", "component":"storage", "action":"putref", "datasource":"ds1", "obj":"data.csv"}' https://<endpoint url>
{"data":"https://<upload url>","status":"success"}
Parameters
action : putref
datasource : Data source name for Avgidea Storage
obj : name of object to upload
Return value
data : URL to upload the object
2. upload a file on the local environment
% curl -X PUT --upload-file . /data.csv https://<upload url>
Parameters
upload-file : Name of the file in the local environment
upload url : URL to upload the object
Downloading an object
To download the file, the following two steps must be performed
Generate a reference for download
Download the file to your local environment
1. Generate references for download
% curl -X POST -H 'content-type: application/json' -d '{"accesskey":"<accesskey>", "secret":"secretkey", "component":"storage", "action":"getref", "datasource":"ds1", "obj":"data.csv"}' https://<endpoint url>
{"data":"https://<download url>","status":"success"}
Parameters
action : getref
datasource : Name of the Avgidea Storage data source
obj : name of object to download
Return value
data : URL from which the object was downloaded
2. Download the file to your local environment
% curl -X GET -o ./data.csv https://<download url>
Parameters
download url : URL from which to download the object
Obtaining a list of files
% curl -X POST -d '{"accesskey":"<accesskey>", "secret":"<secretkey>", "component":"storage", "action":"list", "datasource":"ds1"}' https://<endpoint url> | jq
{
"data": [
{
"name": "data/file1.txt",
"registeredAt": "2024-04-24T09:42:29.628Z",
"size": 20017,
"updatedAt": "2024-04-24T09:42:29.628Z"
},
...
],
"status": "success"
}
Parameters
action : list
datasource : Datasource name of Avgidea Storage
Return value
data : List of objects under Storage Datasource
Deleting a file
% curl -X POST -d '{"accesskey":"<accesskey>", "secret":"<secretkey>", "component":"storage", "action":"delete", "datasource":"ds1", "object":"file1.txt"}' https://<endpoint url>
Parameters
action : delete
datasource : Datasource name of Avgidea Storage
object : Name of object to be deleted
Return value
Object deletion status