Atom Publishing Protocol
The officially supported API for creating, editing and deleting folders and files is the Atom Publishing Protocol. Each Files.Warwick folder is an Atom Collection of files and sub-folders, which are in themselves Collections). The Atom Publishing Protocol (APP) is a RESTful API, which means the HTTP Method sent determines the type of the request. GET
return current information about the folder of file (listing the sub-folders and files in a folder); PUT
replaces the current content of a file with new content, or renames a file or folder; POST
creates a new folder or file; DELETE
purges the folder or file.
The APP service document for your Files.Warwick spaces is:
https://files.warwick.ac.uk/files/api/atom/service
This contains a list of workspaces that you have access to edit, including any personal filespaces, group filespaces, and shared filespaces. This will then allow you to access the Atom feed of the main "Files" folder of your filespace:
https://files.warwick.ac.uk/files/api/atom/folder?account=your-account-name&path=your-account-name/Files/
Sending a GET request to this URL returns a list of <entry> items for each folder and file including information about them.
Both folders and files will have a <link ref="edit"> pointing to the single entry APP endpoint for that folder from which it can be modified. This will be a URL such as:
https://files.warwick.ac.uk/files/api/atom/node?account=your-account-name&path=your-account-name/Files/myfile.txt
which returns an Atom representation of the folder or file and a subset of properties.
Files also contain a <link ref="edit-media">, pointing to an endpoint for editing the content of the file itself:
https://files.warwick.ac.uk/files/api/atom/media?account=your-account-name&path=your-account-name/Files/myfile.txt
In these examples we use two cURL options not seen previously. -X specifies the HTTP Method to use for the operation (described in the first paragraph of this page), and --data-binary specifies a local file to use for the data to send to the server - we use this to specify the file to upload, or the Atom representation of the page. We also use -H to send HTTP Headers.
Examples
Name | Description |
---|---|
Listing files and folders | Using the Files.Warwick API to list files and folders. |
Creating a new folder | Using the Files.Warwick API to create a new folder. |
Uploading a file | Using the Files.Warwick API to upload a file. |
Overwriting a file | Using the Files.Warwick API to replace the contents of a file. |
Renaming folders or files | Using the Files.Warwick API to rename folders or files. |
Purging a folder or file | Using the Files.Warwick API to purge a folder or file. |
Listing permissions | Using the Files.Warwick API to list permissions of files and folders. |
Adding permissions | Using the Files.Warwick API to add new permissions. |
Removing permissions | Using the Files.Warwick API to remove permissions from a folder or file. |