3. FILES
Data, such as body parts, attachments or list of recipients can be encapsulated in the routing order.. However, if they are large and often used, in particular attachments or recipient lists, or if they are customizable templates, it may be useful to upload these elements to the system beforehand, using the 'files' API.
Each user account has a storage space, the organization of which is left free, in particular the tree structure of the directories. When uploading a file, if the directories specified in the access path do not exist, they will be automatically created.
Uploaded files can then be referenced in JSON objects as "@<path>".
POST api/files/<path>
Upload a file to the user directory. If contains directories, they will be automatically created. 3 levels of subdirectories allowed. The operation fails if the file already exists.
PUT api/files/<path>
GET api/files/
Same as POST, except that the uploaded file overwrites any previous version.
Returns the list of files in the root directory of the user account.
GET api/files/<path>
DELETE api/files/<path>
If 'path' is suffixed by a '/' returns the list of files in the 'path/' directory, otherwise, otherwise the file with name 'path'.
Delete the file <path>.
Method
Description
These methods therefore allow the upload of mailing lists, bodies, attachments and images in native format, without Base64 conversion and encapsulation in a JSON object.
Example of uploading the news5_body.htm file to the \DATA\NEWS5 subdirectory of the user account:
POST api/files/DATA/NEWS5/news5_body.htm HTTP/1.1
Authorization: <apikey>
Content-Type: text/html
Content-Lenght: <htm file size>
<html>This is the html body… </html>
-----------------------------------------------------------------------------------------------HTTP/1.1 200 OK
Content-Type: application/json
Content-Lenght: <JSON data size below>
{
"stamp" : {
"date" : <processing date YYMMDDhhmmss>,
"err" : <error code, 0=OK>,
"msg" : <error description>
}
}