multipreview: check params
parent
9d619d5691
commit
1204982c0b
|
@ -111,17 +111,24 @@ class ImageController extends ApiBase
|
||||||
header('Cache-Control: max-age='. 7 * 3600 * 24 .', private');
|
header('Cache-Control: max-age='. 7 * 3600 * 24 .', private');
|
||||||
|
|
||||||
foreach ($files as $bodyFile) {
|
foreach ($files as $bodyFile) {
|
||||||
|
if (!isset($bodyFile['reqid']) || !isset($bodyFile['fileid']) || !isset($bodyFile['x']) || !isset($bodyFile['y']) || !isset($bodyFile['a'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$reqid = $bodyFile['reqid'];
|
$reqid = $bodyFile['reqid'];
|
||||||
$fileid = (int) $bodyFile['fileid'];
|
$fileid = (int) $bodyFile['fileid'];
|
||||||
$x = (int) $bodyFile['x'];
|
$x = (int) $bodyFile['x'];
|
||||||
$y = (int) $bodyFile['y'];
|
$y = (int) $bodyFile['y'];
|
||||||
$a = '1' === $bodyFile['a'];
|
$a = '1' === $bodyFile['a'];
|
||||||
|
if ($fileid <= 0 || $x <= 0 || $y <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$file = $this->getUserFile($fileid);
|
$file = $this->getUserFile($fileid);
|
||||||
if (!$file) {
|
if (!$file) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
// Make sure max preview exists
|
// Make sure max preview exists
|
||||||
$fileId = (string) $file->getId();
|
$fileId = (string) $file->getId();
|
||||||
$folder = $previewRoot->getFolder($fileId);
|
$folder = $previewRoot->getFolder($fileId);
|
||||||
|
@ -139,7 +146,6 @@ class ImageController extends ApiBase
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add this preview to the response
|
// Add this preview to the response
|
||||||
try {
|
|
||||||
$preview = $previewManager->getPreview($file, $x, $y, !$a, 'fill');
|
$preview = $previewManager->getPreview($file, $x, $y, !$a, 'fill');
|
||||||
$content = $preview->getContent();
|
$content = $preview->getContent();
|
||||||
if (empty($content)) {
|
if (empty($content)) {
|
||||||
|
@ -154,6 +160,8 @@ class ImageController extends ApiBase
|
||||||
echo "\n";
|
echo "\n";
|
||||||
echo $content;
|
echo $content;
|
||||||
flush();
|
flush();
|
||||||
|
} catch (\OCP\Files\NotFoundException $e) {
|
||||||
|
continue;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue