File Handling

Files such as device firmware, module firmware, and PEG scripts can be stored on the server and assigned to devices using the API. These files can be handled on the server by using the following commands.

To upload a new file to be stored on the server, there are two steps to be taken:

First, the file meta must be created, which creates a location on the server for the file to be stored. This is a POST API call with the body containing meta-information about the file.
An example is shown below.

Once the API call is received and the file meta is created, a response will be sent containing key information to be used in the next step. The bucket and data key are among the required elements in the body for the next API call.

Once the file meta has been created and the response containing the file meta information has been received, the file can then be uploaded using a POST call with the file(s) passed in the body of the call. This POST call must also contain the required file meta information received from the response in the previous file meta creation API call. An example of the code for this step is shown below.

To retrieve a file, the API to use is a GET call with the authentication cookie passed in the cookies. The File ID must be passed in the URL. Example shown below.