multipreview: check params
parent
9d619d5691
commit
1204982c0b
|
@ -111,35 +111,41 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure max preview exists
|
|
||||||
$fileId = (string) $file->getId();
|
|
||||||
$folder = $previewRoot->getFolder($fileId);
|
|
||||||
$hasMax = false;
|
|
||||||
foreach ($folder->getDirectoryListing() as $preview) {
|
|
||||||
$name = $preview->getName();
|
|
||||||
if (str_contains($name, '-max')) {
|
|
||||||
$hasMax = true;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!$hasMax) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add this preview to the response
|
|
||||||
try {
|
try {
|
||||||
|
// Make sure max preview exists
|
||||||
|
$fileId = (string) $file->getId();
|
||||||
|
$folder = $previewRoot->getFolder($fileId);
|
||||||
|
$hasMax = false;
|
||||||
|
foreach ($folder->getDirectoryListing() as $preview) {
|
||||||
|
$name = $preview->getName();
|
||||||
|
if (str_contains($name, '-max')) {
|
||||||
|
$hasMax = true;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$hasMax) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add this preview to the response
|
||||||
$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