File Upload Requests(3.2)

This section includes the HTTP requests to use for managing uploaded files to a container, using the standard HTTP methods DELETE, GET, POST and PUT. Each command includes a curl example.

By default, you upload files to the folder file.api in the temporary directory determined by the value set for the Desktop property pico.tmpdir. To rename where the files are uploaded to in the temporary directory, set the property api.file.storage.name in the Platform. 

Retrieving Names of Files

To retrieve the names of uploaded files in the file directory in a JSON array, use the following command with HTTP method GET, as in the example.

http://<platform-host>:<webinterface-port>/webapi/<version>/file 

Example - Retrieving file names request

$ curl -X GET "http://localhost:9000/webapi/v1/file" -u mzadmin:dr 

Uploading a File

To upload a file to the temporary directory, use the following command with HTTP method POST, as in the example.

The following headers are required:

Content-Length: <file size>

Content-Type: application/octet-stream

http://<platform-host>:<webinterface-port>/webapi/<version>/file/<file name>

Example - Uploading a file request

$ curl -X POST "http://localhost:9000/webapi/v1/file/myfile" -u mzadmin:dr --data-binary @myfile

Updating an Uploaded File

To update an uploaded file, use the following command with HTTP method PUT, as in the example.

The following headers are required:

Content-Length: <file size>

Content-Type: application/octet-stream

http://<platform-host>:<webinterface-port>/webapi/<version>/file/<file name>

Example - Updating a file request

$ curl -X PUT "http://localhost:9000/webapi/v1/file/myfile" -u mzadmin:dr --data-binary @myfile

Deleting a File

To delete a file from a container, use the following command with HTTP method DELETE, as in the example:

http://<platform-host>:<webinterface-port>/webapi/<version>/file/<file name>

Example - Deleting a file request

$ curl -X DELETE "http://localhost:9000/webapi/v1/file/myfile" -u mzadmin:dr

Updating Last Modified Time on File

To update the last modified time on a file to the current time, for example, to delay the file deletion, use the following command with HTTP method PUT, as in the example.

http://<platform-host>:<webinterface-port>/webapi/<version>/file/touch/<file name>

Example - Updating last modified time request

$ curl -X PUT "http://localhost:9000/webapi/v1/file/touch/myfile" -u mzadmin:dr