fix getFileInfo
This commit is contained in:
parent
f992856476
commit
a88fd4e2fe
@ -17,6 +17,7 @@ use OCP\AppFramework\Http\ContentSecurityPolicy;
|
|||||||
use OCP\AppFramework\Http\TemplateResponse;
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
use OCP\Files\FileInfo;
|
use OCP\Files\FileInfo;
|
||||||
use OCP\Files\Folder;
|
use OCP\Files\Folder;
|
||||||
|
use OCP\Files\InvalidPathException;
|
||||||
use OCP\Files\IRootFolder;
|
use OCP\Files\IRootFolder;
|
||||||
use OCP\Files\NotFoundException;
|
use OCP\Files\NotFoundException;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
@ -141,6 +142,8 @@ class PageController extends Controller {
|
|||||||
parse_str(parse_url($path, PHP_URL_QUERY), $query);
|
parse_str(parse_url($path, PHP_URL_QUERY), $query);
|
||||||
if (isset($query['path']) && is_string($query['path'])) {
|
if (isset($query['path']) && is_string($query['path'])) {
|
||||||
$node = $node->get($query['path']);
|
$node = $node->get($query['path']);
|
||||||
|
} elseif (isset($query['files']) && is_string($query['files'])) {
|
||||||
|
$node = $node->get($query['files']);
|
||||||
} else {
|
} else {
|
||||||
throw new NotFoundException('Shared file path or name not set');
|
throw new NotFoundException('Shared file path or name not set');
|
||||||
}
|
}
|
||||||
@ -154,12 +157,14 @@ class PageController extends Controller {
|
|||||||
->getId();
|
->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var string[] $pathInfo */
|
|
||||||
$pathInfo = pathInfo($filePath);
|
$pathInfo = pathInfo($filePath);
|
||||||
|
if (!is_array($pathInfo)) {
|
||||||
|
throw new InvalidPathException("Can not get info for $filePath");
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'fileName' => $pathInfo['filename'],
|
'fileName' => $pathInfo['filename'],
|
||||||
'fileType' => strtolower($pathInfo['extension']),
|
'fileType' => strtolower($pathInfo['extension'] ?? ''),
|
||||||
'fileId' => $fileId
|
'fileId' => $fileId
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ class Time {
|
|||||||
* @return int the current unix time in miliseconds
|
* @return int the current unix time in miliseconds
|
||||||
*/
|
*/
|
||||||
public function getMicroTime(): int {
|
public function getMicroTime(): int {
|
||||||
list($millisecs, $secs) = explode(" ", microtime());
|
list($millisecs, $secs) = explode(' ', microtime());
|
||||||
return (int) ($secs . substr($millisecs, 2, 6));
|
return (int) ($secs . substr($millisecs, 2, 6));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user