MENU

Files

Endpoint

https://api.cms-tool.net/api/files/   (For the public files repository)

https://api.cms-tool.net/api/filesSecure/  (For secure files repository)

Description

The files API allows you to 

  • list the files on your website, for a given directory. 
  • obtain information about a specific file, such as size and modified date
  • upload a file into the specified directory
  • download the file from a secure location.

Requirement: You will need a Live paying site to access this endpoint

File Path

The filepath can either be specified in the endpoint URL or via additional parameter. If uploading a file, the filepath is the directory, not the final filename path. 

Endpoint: https://api.cms-tool.net/api/files/images/mysubdir/myimage.gif

Target File Path:    filePath=/images/mysubdir/myimage.gif

Upload files

Upload File: uploadFile=[FILETYPE]

Upload Filename: as per the filename descriptor for the file in the multipart form post.

Example Post File

Multipart POST:  /api/files/images/subdir/

or 

Multipart POST:  /api/files/images  

Where multipart data includes.

  • uploadFile=[FILEDATA]
  • filePath=/images/subdir/   (either this or as per the URI extension above, as to the directory where the file should be saved )
  • fileName=myimage.jpg    (this is optional, it will use the filename of the uploadFile otherwise)


Example Return JSON

GET /api/files/images

or

GET /api/files?filePath=images

{

   "endPoint": "files",

   "requestedFilePath": "images",

   "data": [

       {

           "filename": "image1.gif",

           "exists": true,

           "lastModified": 1285495937000,

           "sizeBytes": 4372

       },

       {

           "filename": "Logo.jpg",

           "exists": true,

           "lastModified": 1562195390000,

           "sizeBytes": 102670

       },

       {

           "filename": "banner.jpg",

           "exists": true,

           "lastModified": 1484267193000,

           "sizeBytes": 96805

       }

   ],

   "success": false,

   "dataType": "directoryList"

}

Example Failed Return JSON

/api/files?filePath=images/help

{

   "endPoint": "files",

   "requestedFilePath": "images/help",

   "data": {

       "filename": "help",

       "exists": false,

       "lastModified": 0,

       "sizeBytes": 0

   },

   "success": false,

   "dataType": "file"

}