Get file or folder metadata

Get information on a file or folder.

Request

  • Method: GET
  • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
    • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
  • Path: /api/v2/admin/sites/[siteId]/storage/[filePath]?meta
  • Authorization header: This should contain the authorization token. Here is how to obtain the token.
  • Required Permissions: Can use SFTP & File Manager

Response

Returns a storage entity object that following properties:

  • type : "file" or "folder" (string)
  • name : name of the file (string)
  • size : size of the file (integer)
  • lastModified: last modified date, can be null (dateTime)
  • links : an array of link objects (array)
  • rel -storage : URL for the API endpoint to perform other operations on the file (string)

Accepts and returns JSON as Content-Type.


Request:

GET /api/v2/admin/sites/current/storage/images/cat.jpg?meta HTTPS/1.1
Accept: application/json
Authorization: c50f6e6be0d1481ca0d8eb0c63642fdd171c17846af04cdd95676a0888141f73

Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "type": "file",
    "name": "cat.jpg",
    "size": 1024,
    "lastModified": "Mon, 26 Jul 2010 12:45:26 GMT",
    "links": [
        {
            "rel": "storage",
            "uri": "/api/v2/admin/sites/current/storage/images/cat.jpg"
        }
    ]
}

Sample code

Get file metadata

var request = $.ajax({
    url: "/api/v2/admin/sites/current/storage/images/desc.txt?meta",
    type: "GET",
    accept: "application/json",
    headers: {
        "Authorization": $.cookie('access_token')
    }
});
request.done(function (msg) {
    console.log(msg);
})
request.fail(function (jqXHR) {
    console.log("Request failed.");
    console.log("Error code: " + jqXHR.status);
    console.log("Error text: " + jqXHR.statusText);
    console.log("Response text: " + jqXHR.responseText);
})

Get folder metadata

var request = $.ajax({
    url: "/api/v2/admin/sites/current/storage/images/?meta",
    type: "GET",
    accept: "application/json",
    headers: {
        "Authorization": $.cookie('access_token')
    }
});
request.done(function (msg) {
    console.log(JSON.stringify(msg));
})
request.fail(function (jqXHR) {
    console.log("Request failed.");
    console.log("Error code: " + jqXHR.status);
    console.log("Error text: " + jqXHR.statusText);
    console.log("Response text: " + jqXHR.responseText);
})

Error codes

This method will return the following error codes:

  • 200 - OK
  • 400 - Bad request:
    • 104000 - Generic FileAPI error
    • 104001 - File not found
    • 104002 - Not a file
    • 104003 - Not enough privileges
    • 104004 - Invalid login multiple sites
    • 104009- Path not found
    • 104014 - Name required
    • 104023 - Unauthorized access
    • 104028 - File or folder name too long
  • 401- when authentication token is incorrect
  • 404 - the folder does not exist