searchFiles

Returns the Files that match the search criteria.

searchFiles

Returns the Files that match the search criteria.

Top ↑

Syntax

object searchFiles(
    string api_key,
  [ string search_criteria,
    int limit,
    int offset,
    string sort_by,
    string sort_order ] 
);

Parameters

api_key (string)

The key required to access the API. See Getting Started for more information.

search_criteria (string - optional)

An array of search criteria. See the remarks section below for the list of values which are searchable.
If you do not specify search criteria, all Files are returned.

limit (int - optional)

Maximum number of items to return.

offset (int - optional)

Number of items to skip before beginning to return results. See Using Search Methods for information about using the offset parameter with the limit parameter to include pagination in your results.

sort_by (string - optional)

The name of the value to sort the results by.

sort_order (string - optional)

The order the results are returned in (either ascending or descending). The default is descending. Valid values are:

  • DESC - Sort from highest to lowest (default).
  • ASC - Sort from lowest to highest.

Return Value

Returns an object containing zero or more objects of File details. See the remarks section below for the list of values this method returns.

Examples

Search for Files with the name 'image'

$api = new Api($url, 'YOURAPIKEY');

$search_criteria = array(
    array('basename', 'exactly', 'image')
);

$file = $api->invokeMethod('searchFiles', $search_criteria);
{
    "id": 1,
    "method": "searchFiles",
    "params": [
        "YOURAPIKEY",
        [
            ["basename", "exactly", "image"],

        ]
    ]
}
{
    "id": 1,
    "result": [
        {
            "id": "1234567",
            "folder_id": "56789",
            "basename": "image",
            "extension": ".png",
            "size": "24",
            "creation_time": "1362352224",
            "image_width": "0",
            "image_height": "0",
            "mime_type": "image\/png",
            "last_modified_time": "1362352224",
            "last_modified_user_id": "50247",
            "name": "image.png",
            "url": "http:\/\/example.com\/image.png"
        }
    ],
    "error": null
}

Remarks

The following table shows the values that are returned.

Key Searchable Value
id Yes The File Id.
folder_id Yes The Folder ID the File belongs to.
basename Yes The File base name (without File extension).
extension Yes The File extension (jpeg, gif, png, etc).
size Yes The File size in bytes.
creation_time Yes Unix timestamps of when the File was created
image_width Yes If File is an image, the image width in pixels.
image_height Yes If File is an image, the file height in pixels.
mime_type Yes The File type.
last_modified_time Yes Unix timestamps of when the File was last modified.
last_modified_user_id Yes Id of the User who modified the File last time.
name Yes The filename (including the file extension)
url Yes A URL than can be used to access the file from the web.

Error Codes

This method may return the following error code in addition to the standard error codes:

Code Error Description
311 Invalid Search Parameter Format search_criteria is not valid

See Also