Storage API

Storage API PRODUCT     AVGIDEA, INC. 

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


% 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

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

Return value


2. upload a file on the local environment

% curl -X PUT --upload-file . /data.csv https://<upload url>

Parameters


Downloading an object

To download the file, the following two steps must be performed

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

Return value


2. Download the file to your local environment

% curl -X GET -o ./data.csv https://<download url>

Parameters


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

Return value


Deleting a file

% curl -X POST -d '{"accesskey":"<accesskey>", "secret":"<secretkey>", "component":"storage", "action":"delete", "datasource":"ds1", "object":"file1.txt"}' https://<endpoint url>


Parameters

Return value