1
0
Fork 0
mirror of synced 2024-06-27 02:31:04 +12:00

Merge pull request #2798 from appwrite/feat-image-preview-limit

Image above 10MB shows default image icon as preview
This commit is contained in:
Eldad A. Fux 2022-02-16 13:35:07 +02:00 committed by GitHub
commit 559d13dd3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 3 deletions

View file

@ -2,6 +2,7 @@
return [ // Based on this list @see http://stackoverflow.com/a/4212908/2299554
'default' => __DIR__.'/logos/none.png',
'default_image' => __DIR__.'/logos/image.png',
// Video Files
'video/mp4' => __DIR__.'/logos/video.png',

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

View file

@ -915,8 +915,14 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview')
$cipher = $file->getAttribute('openSSLCipher');
$mime = $file->getAttribute('mimeType');
if (!\in_array($mime, $inputs)) {
$path = (\array_key_exists($mime, $fileLogos)) ? $fileLogos[$mime] : $fileLogos['default'];
if (!\in_array($mime, $inputs) || $file->getAttribute('sizeActual') > APP_LIMIT_PREVIEW) {
if(!\in_array($mime, $inputs)) {
$path = (\array_key_exists($mime, $fileLogos)) ? $fileLogos[$mime] : $fileLogos['default'];
} else {
// it was an image but the file size exceeded the limit
$path = $fileLogos['default_image'];
}
$algorithm = null;
$cipher = null;
$background = (empty($background)) ? 'eceff1' : $background;
@ -924,6 +930,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview')
$key = \md5($path . $width . $height . $gravity . $quality . $borderWidth . $borderColor . $borderRadius . $opacity . $rotation . $background . $output);
}
$compressor = new GZIP();
if (!$deviceFiles->exists($path)) {

View file

@ -67,6 +67,7 @@ const APP_LIMIT_USERS = 10000;
const APP_LIMIT_ANTIVIRUS = 20000000; //20MB
const APP_LIMIT_ENCRYPTION = 20000000; //20MB
const APP_LIMIT_COMPRESSION = 20000000; //20MB
const APP_LIMIT_PREVIEW = 10000000; //10MB file size limit for preview endpoint
const APP_CACHE_BUSTER = 201;
const APP_VERSION_STABLE = '0.13.0';
const APP_DATABASE_ATTRIBUTE_EMAIL = 'email';

View file

@ -1 +1 @@
Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image.
Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. Preview is supported only for image files smaller than 10MB.