diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/storage.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/storage.php b/lib/storage.php index ce65d39c..51cf6b66 100644 --- a/lib/storage.php +++ b/lib/storage.php @@ -72,6 +72,26 @@ class Storage { return $list; } + public static function getDocumentById($fileId){ + $root = \OC::$server->getUserFolder(); + $ret = array(); + + // If type of fileId is a string, then it + // doesn't work for shared documents, lets cast to int everytime + $document = $root->getById((int)$fileId)[0]; + if ($document === null){ + error_log('File with file id, ' . $fileId . ', not found'); + return $ret; + } + + $ret['mimetype'] = $document->getMimeType(); + $ret['path'] = $root->getRelativePath($document->getPath()); + $ret['name'] = $document->getName(); + $ret['fileid'] = $fileId; + + return $ret; + } + public static function resolvePath($fileId){ $list = array_filter( self::searchDocuments(), |