MENU

Files

Endpoint

https://api.website.world/webapps/api/files

Description

The files API allows you to list the files on your website, for a given directory. You will need a Live paying site to access this endpoint.

Or to obtain file information about the target pathname

Or to upload a file into the specified directory. 

Endpoint: /api/files

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

Target File Directory For Uploads:    filepath=/images/mysubdiranywhere/

Upload File: uploadFile=[FILETYPE]

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

Example Post File

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

or 

Multipart POST:  /webapps/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 /webapps/api/files/images

or

GET /webapps/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

/webapps/api/files?filePath=images/help

{

   "endPoint": "files",

   "requestedFilePath": "images/help",

   "data": {

       "filename": "help",

       "exists": false,

       "lastModified": 0,

       "sizeBytes": 0

   },

   "success": false,

   "dataType": "file"

}