Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
feat(file): add size and type info of files on API response
Browse files Browse the repository at this point in the history
Signed-off-by: Domingo Oropeza <doropeza@teclib.com>
  • Loading branch information
DIOHz0r committed Mar 2, 2018
1 parent 2840a7b commit 88cde20
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions inc/file.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,11 @@ public function post_addItem() {
public function post_getFromDB() {
// Check the user can view this itemtype and can view this item
if ($this->canView() && $this->canViewItem()) {
if (isAPI()
&& (isset($_SERVER['HTTP_ACCEPT']) && $_SERVER['HTTP_ACCEPT'] == 'application/octet-stream'
$filename = FLYVEMDM_FILE_PATH . '/' . $this->fields['source'];
$isFile = is_file($filename);
$this->fields['filesize'] = ($isFile) ? fileSize($filename) : 0;
$this->fields['mime_type'] = ($isFile) ? mime_content_type($filename) : '';
if (isAPI() && (isset($_SERVER['HTTP_ACCEPT']) && $_SERVER['HTTP_ACCEPT'] == 'application/octet-stream'
|| isset($_GET['alt']) && $_GET['alt'] == 'media')) {
$this->sendFile(); // and terminate script
}
Expand Down

0 comments on commit 88cde20

Please sign in to comment.