diff options
-rw-r--r-- | doc/api/api_files.md | 103 | ||||
-rw-r--r-- | include/api_zot.php | 8 | ||||
-rw-r--r-- | include/attach.php | 4 |
3 files changed, 112 insertions, 3 deletions
diff --git a/doc/api/api_files.md b/doc/api/api_files.md new file mode 100644 index 000000000..c2a10fce5 --- /dev/null +++ b/doc/api/api_files.md @@ -0,0 +1,103 @@ +API files +========= + +List file storage (attach DB) + +GET /api/z/1.0/files + + +Options: + + - hash + return only entries matching hash (exactly) + + - filename + return only entries matching filename (substring) + + - filetype + return only entries matching filetype/mimetype (substring) + + - start + start at record (default 0) + + - records + number of records to return or 0 for unlimited + + + +Example: + +curl -u mychannel:mypassword https://xyz.macgirvin.com/api/z/1.0/files -d filetype=multipart/mixed + + +Returns: + + { + + "success": true, + "results": [ + { + "id": "1", + "aid": "1", + "uid": "2", + "hash": "44ee8b2a1a7f36dea07b93b7747a2383a1bc0fdd08339e8928bfcbe45f65d939", + "filename": "Profile Photos", + "filetype": "multipart/mixed", + "filesize": "0", + "revision": "0", + "folder": "", + "os_storage": "1", + "is_dir": "1", + "is_photo": "0", + "flags": "0", + "created": "2016-01-02 21:51:17", + "edited": "2016-01-02 21:51:17", + "allow_cid": "", + "allow_gid": "", + "deny_cid": "", + "deny_gid": "" + }, + { + "id": "12", + "aid": "1", + "uid": "2", + "hash": "71883f1fc64af33889229cbc79c5a056deeec5fc277d765f182f19073e1b2998", + "filename": "Cover Photos", + "filetype": "multipart/mixed", + "filesize": "0", + "revision": "0", + "folder": "", + "os_storage": "1", + "is_dir": "1", + "is_photo": "0", + "flags": "0", + "created": "2016-01-15 00:24:33", + "edited": "2016-01-15 00:24:33", + "allow_cid": "", + "allow_gid": "", + "deny_cid": "", + "deny_gid": "" + }, + { + "id": "16", + "aid": "1", + "uid": "2", + "hash": "f48f7ec3278499d1dd86b72c3207beaaf4717b07df5cc9b373f14d7aad2e1bcd", + "filename": "2016-01", + "filetype": "multipart/mixed", + "filesize": "0", + "revision": "0", + "folder": "", + "os_storage": "1", + "is_dir": "1", + "is_photo": "0", + "flags": "0", + "created": "2016-01-22 03:24:55", + "edited": "2016-01-22 03:26:57", + "allow_cid": "", + "allow_gid": "", + "deny_cid": "", + "deny_gid": "" + } + ] + } diff --git a/include/api_zot.php b/include/api_zot.php index a7a377bf4..35025f5f8 100644 --- a/include/api_zot.php +++ b/include/api_zot.php @@ -118,7 +118,13 @@ function api_attach_list($type) { logger('api_user: ' . api_user()); - json_return_and_die(attach_list_files(api_user(),get_observer_hash(),'','','','created asc')); + $hash = ((array_key_exists('filehash',$_REQUEST)) ? $_REQUEST['filehash'] : ''); + $filename = ((array_key_exists('filename',$_REQUEST)) ? $_REQUEST['filename'] : ''); + $filetype = ((array_key_exists('filetype',$_REQUEST)) ? $_REQUEST['filetype'] : ''); + $start = ((array_key_exists('start',$_REQUEST)) ? intval($_REQUEST['start']) : 0); + $records = ((array_key_exists('records',$_REQUEST)) ? intval($_REQUEST['records']) : 0); + + json_return_and_die(attach_list_files(api_user(),get_observer_hash(),$hash,$filename,$filetype,'created asc',$start,$records)); } diff --git a/include/attach.php b/include/attach.php index ac0185f5d..504601b55 100644 --- a/include/attach.php +++ b/include/attach.php @@ -197,10 +197,10 @@ function attach_list_files($channel_id, $observer, $hash = '', $filename = '', $ $sql_extra .= protect_sprintf(" and hash = '" . dbesc($hash) . "' "); if($filename) - $sql_extra .= protect_sprintf(" and filename like '@" . dbesc($filename) . "@' "); + $sql_extra .= protect_sprintf(" and filename like '%" . dbesc($filename) . "%' "); if($filetype) - $sql_extra .= protect_sprintf(" and filetype like '@" . dbesc($filetype) . "@' "); + $sql_extra .= protect_sprintf(" and filetype like '%" . dbesc($filetype) . "%' "); if($entries) $limit = " limit " . intval($start) . ", " . intval(entries) . " "; |