Merge pull request #1008 from appwrite/feat-new-image-features
feat-new-image-features
This commit is contained in:
commit
5148c5419c
|
@ -115,7 +115,7 @@ App::post('/v1/storage/files')
|
|||
$iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM));
|
||||
$data = OpenSSL::encrypt($data, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag);
|
||||
|
||||
if (!$device->write($path, $data)) {
|
||||
if (!$device->write($path, $data, $mimeType)) {
|
||||
throw new Exception('Failed to save file', 500);
|
||||
}
|
||||
|
||||
|
@ -242,13 +242,18 @@ App::get('/v1/storage/files/:fileId/preview')
|
|||
->param('width', 0, new Range(0, 4000), 'Resize preview image width, Pass an integer between 0 to 4000.', true)
|
||||
->param('height', 0, new Range(0, 4000), 'Resize preview image height, Pass an integer between 0 to 4000.', true)
|
||||
->param('quality', 100, new Range(0, 100), 'Preview image quality. Pass an integer between 0 to 100. Defaults to 100.', true)
|
||||
->param('borderWidth', 0, new Range(0, 100), 'Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.', true)
|
||||
->param('borderColor', '', new HexColor(), 'Preview image border color. Use a valid HEX color, no # is needed for prefix.', true)
|
||||
->param('borderRadius', 0, new Range(0, 4000), 'Preview image border radius in pixels. Pass an integer between 0 to 4000.', true)
|
||||
->param('opacity', 1, new Range(0,1), 'Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.', true)
|
||||
->param('rotation', 0, new Range(0,360), 'Preview image rotation in degrees. Pass an integer between 0 and 360.', true)
|
||||
->param('background', '', new HexColor(), 'Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.', true)
|
||||
->param('output', '', new WhiteList(\array_keys(Config::getParam('storage-outputs')), true), 'Output format type (jpeg, jpg, png, gif and webp).', true)
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->inject('project')
|
||||
->inject('projectDB')
|
||||
->action(function ($fileId, $width, $height, $quality, $background, $output, $request, $response, $project, $projectDB) {
|
||||
->action(function ($fileId, $width, $height, $quality, $borderWidth, $borderColor, $borderRadius, $opacity, $rotation, $background, $output, $request, $response, $project, $projectDB) {
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $project */
|
||||
|
@ -273,7 +278,7 @@ App::get('/v1/storage/files/:fileId/preview')
|
|||
$fileLogos = Config::getParam('storage-logos');
|
||||
|
||||
$date = \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)).' GMT'; // 45 days cache
|
||||
$key = \md5($fileId.$width.$height.$quality.$background.$storage.$output);
|
||||
$key = \md5($fileId.$width.$height.$quality.$borderWidth.$borderColor.$borderRadius.$opacity.$rotation.$background.$storage.$output);
|
||||
|
||||
$file = $projectDB->getDocument($fileId);
|
||||
|
||||
|
@ -293,7 +298,7 @@ App::get('/v1/storage/files/:fileId/preview')
|
|||
$cipher = null;
|
||||
$background = (empty($background)) ? 'eceff1' : $background;
|
||||
$type = \strtolower(\pathinfo($path, PATHINFO_EXTENSION));
|
||||
$key = \md5($path.$width.$height.$quality.$background.$storage.$output);
|
||||
$key = \md5($path.$width.$height.$quality.$borderWidth.$borderColor.$borderRadius.$opacity.$rotation.$background.$storage.$output);
|
||||
}
|
||||
|
||||
$compressor = new GZIP();
|
||||
|
@ -337,11 +342,28 @@ App::get('/v1/storage/files/:fileId/preview')
|
|||
$image = new Image($source);
|
||||
|
||||
$image->crop((int) $width, (int) $height);
|
||||
|
||||
if (!empty($opacity) || $opacity==0) {
|
||||
$image->setOpacity($opacity);
|
||||
}
|
||||
|
||||
if (!empty($background)) {
|
||||
$image->setBackground('#'.$background);
|
||||
}
|
||||
|
||||
|
||||
if (!empty($borderWidth) ) {
|
||||
$image->setBorder($borderWidth, '#'.$borderColor);
|
||||
}
|
||||
|
||||
if (!empty($borderRadius)) {
|
||||
$image->setBorderRadius($borderRadius);
|
||||
}
|
||||
|
||||
if (!empty($rotation)) {
|
||||
$image->setRotation($rotation);
|
||||
}
|
||||
|
||||
$output = (empty($output)) ? $type : $output;
|
||||
|
||||
$data = $image->output($output, $quality);
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
"utopia-php/swoole": "0.2.*",
|
||||
"utopia-php/system": "0.4.*",
|
||||
"utopia-php/storage": "0.4.*",
|
||||
"utopia-php/image": "0.1.*",
|
||||
"utopia-php/image": "0.2.*",
|
||||
|
||||
"resque/php-resque": "1.3.6",
|
||||
"matomo/device-detector": "4.1.0",
|
||||
|
|
191
composer.lock
generated
191
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "a5a066bf0b739b7b412149aeb0e9a396",
|
||||
"content-hash": "60b57e034676287a703cf42b1de0c60d",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/jwt",
|
||||
|
@ -1755,16 +1755,16 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/image",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/image.git",
|
||||
"reference": "66e38db211b1d6fe93de09d82606641e0f996e42"
|
||||
"reference": "0754955a165483852184d1215cc3bf659432d23a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/image/zipball/66e38db211b1d6fe93de09d82606641e0f996e42",
|
||||
"reference": "66e38db211b1d6fe93de09d82606641e0f996e42",
|
||||
"url": "https://api.github.com/repos/utopia-php/image/zipball/0754955a165483852184d1215cc3bf659432d23a",
|
||||
"reference": "0754955a165483852184d1215cc3bf659432d23a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1802,9 +1802,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/image/issues",
|
||||
"source": "https://github.com/utopia-php/image/tree/0.1.0"
|
||||
"source": "https://github.com/utopia-php/image/tree/0.2.1"
|
||||
},
|
||||
"time": "2021-02-19T05:09:46+00:00"
|
||||
"time": "2021-04-13T07:47:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/locale",
|
||||
|
@ -2276,12 +2276,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/amphp/byte-stream.git",
|
||||
"reference": "f813a658f0446192c5e17f96727070ee9342b93a"
|
||||
"reference": "7a64a9ad336fc5e1e70b1c1fc1e9618a7027332e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/amphp/byte-stream/zipball/f813a658f0446192c5e17f96727070ee9342b93a",
|
||||
"reference": "f813a658f0446192c5e17f96727070ee9342b93a",
|
||||
"url": "https://api.github.com/repos/amphp/byte-stream/zipball/7a64a9ad336fc5e1e70b1c1fc1e9618a7027332e",
|
||||
"reference": "7a64a9ad336fc5e1e70b1c1fc1e9618a7027332e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2346,7 +2346,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2020-08-30T19:23:04+00:00"
|
||||
"time": "2021-04-05T20:23:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "appwrite/sdk-generator",
|
||||
|
@ -2544,16 +2544,16 @@
|
|||
},
|
||||
{
|
||||
"name": "composer/xdebug-handler",
|
||||
"version": "1.4.5",
|
||||
"version": "1.4.x-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/composer/xdebug-handler.git",
|
||||
"reference": "f28d44c286812c714741478d968104c5e604a1d4"
|
||||
"reference": "f27e06cd9675801df441b3656569b328e04aa37c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f28d44c286812c714741478d968104c5e604a1d4",
|
||||
"reference": "f28d44c286812c714741478d968104c5e604a1d4",
|
||||
"url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f27e06cd9675801df441b3656569b328e04aa37c",
|
||||
"reference": "f27e06cd9675801df441b3656569b328e04aa37c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2561,7 +2561,8 @@
|
|||
"psr/log": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8"
|
||||
"phpstan/phpstan": "^0.12.55",
|
||||
"symfony/phpunit-bridge": "^4.2 || ^5"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
|
@ -2587,7 +2588,7 @@
|
|||
"support": {
|
||||
"irc": "irc://irc.freenode.org/composer",
|
||||
"issues": "https://github.com/composer/xdebug-handler/issues",
|
||||
"source": "https://github.com/composer/xdebug-handler/tree/1.4.5"
|
||||
"source": "https://github.com/composer/xdebug-handler/tree/1.4.6"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -2603,7 +2604,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-11-13T08:04:11+00:00"
|
||||
"time": "2021-03-25T17:01:18+00:00"
|
||||
},
|
||||
{
|
||||
"name": "dnoegel/php-xdg-base-dir",
|
||||
|
@ -3509,12 +3510,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||
"reference": "ad069801f3d0cdb7102e58afd5f9f32834ec7160"
|
||||
"reference": "f6293e1b30a2354e8428e004689671b83871edde"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ad069801f3d0cdb7102e58afd5f9f32834ec7160",
|
||||
"reference": "ad069801f3d0cdb7102e58afd5f9f32834ec7160",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f6293e1b30a2354e8428e004689671b83871edde",
|
||||
"reference": "f6293e1b30a2354e8428e004689671b83871edde",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3570,7 +3571,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
|
||||
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2"
|
||||
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.6"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -3578,7 +3579,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-02-08T09:55:27+00:00"
|
||||
"time": "2021-03-28T07:26:59+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-file-iterator",
|
||||
|
@ -3586,12 +3587,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
|
||||
"reference": "b2ce4cf415b9989fac88e8c27c39b5ba2faad72b"
|
||||
"reference": "97eb187efc3560da69c5b501235cd3eb1ebfec86"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/b2ce4cf415b9989fac88e8c27c39b5ba2faad72b",
|
||||
"reference": "b2ce4cf415b9989fac88e8c27c39b5ba2faad72b",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/97eb187efc3560da69c5b501235cd3eb1ebfec86",
|
||||
"reference": "97eb187efc3560da69c5b501235cd3eb1ebfec86",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3639,7 +3640,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-17T06:17:19+00:00"
|
||||
"time": "2021-04-02T08:22:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-invoker",
|
||||
|
@ -3647,12 +3648,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-invoker.git",
|
||||
"reference": "e2905d5648ac5e9bd0aa85b50d240e5890f76493"
|
||||
"reference": "de89b92643f75d97135fd0f895d4369630952c95"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/e2905d5648ac5e9bd0aa85b50d240e5890f76493",
|
||||
"reference": "e2905d5648ac5e9bd0aa85b50d240e5890f76493",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/de89b92643f75d97135fd0f895d4369630952c95",
|
||||
"reference": "de89b92643f75d97135fd0f895d4369630952c95",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3703,7 +3704,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-17T06:17:27+00:00"
|
||||
"time": "2021-04-02T08:22:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-text-template",
|
||||
|
@ -3711,12 +3712,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-text-template.git",
|
||||
"reference": "e6a2483ffd3659d723996fb8b2ca638244b87e7c"
|
||||
"reference": "f46a87d94ad351b46c836f6cdda98795e8a6c979"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/e6a2483ffd3659d723996fb8b2ca638244b87e7c",
|
||||
"reference": "e6a2483ffd3659d723996fb8b2ca638244b87e7c",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/f46a87d94ad351b46c836f6cdda98795e8a6c979",
|
||||
"reference": "f46a87d94ad351b46c836f6cdda98795e8a6c979",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3763,7 +3764,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-17T06:17:59+00:00"
|
||||
"time": "2021-04-02T08:22:46+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-timer",
|
||||
|
@ -3771,12 +3772,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-timer.git",
|
||||
"reference": "c0187813193d3709a455b94916bbee2881a1c6e3"
|
||||
"reference": "bd80d581ad411a5a4b7e613541a7f4cd09cf0da9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/c0187813193d3709a455b94916bbee2881a1c6e3",
|
||||
"reference": "c0187813193d3709a455b94916bbee2881a1c6e3",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/bd80d581ad411a5a4b7e613541a7f4cd09cf0da9",
|
||||
"reference": "bd80d581ad411a5a4b7e613541a7f4cd09cf0da9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3823,7 +3824,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-17T06:17:35+00:00"
|
||||
"time": "2021-04-02T08:22:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
|
@ -3982,12 +3983,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/cli-parser.git",
|
||||
"reference": "845853b8c553f6b61d9a708b8f26066806bcc7dd"
|
||||
"reference": "e59dfbeeaf6ccdff168c537427cbc9f7fed6b160"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/845853b8c553f6b61d9a708b8f26066806bcc7dd",
|
||||
"reference": "845853b8c553f6b61d9a708b8f26066806bcc7dd",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/e59dfbeeaf6ccdff168c537427cbc9f7fed6b160",
|
||||
"reference": "e59dfbeeaf6ccdff168c537427cbc9f7fed6b160",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -4031,7 +4032,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-17T06:18:24+00:00"
|
||||
"time": "2021-04-02T08:23:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/code-unit",
|
||||
|
@ -4095,12 +4096,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git",
|
||||
"reference": "ab4d610891809670894a4fc260c17e5d5960ba4c"
|
||||
"reference": "f7ee1d817bdd8a8bdfb76b11fa851204132ef6d9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ab4d610891809670894a4fc260c17e5d5960ba4c",
|
||||
"reference": "ab4d610891809670894a4fc260c17e5d5960ba4c",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/f7ee1d817bdd8a8bdfb76b11fa851204132ef6d9",
|
||||
"reference": "f7ee1d817bdd8a8bdfb76b11fa851204132ef6d9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -4143,7 +4144,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-17T06:16:16+00:00"
|
||||
"time": "2021-04-02T08:20:56+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/comparator",
|
||||
|
@ -4151,12 +4152,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/comparator.git",
|
||||
"reference": "d3d66b8faa86ac57e1236d576ad003f73097c9cd"
|
||||
"reference": "604de433dd3e1467ded9a92414b3561a812554c5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/d3d66b8faa86ac57e1236d576ad003f73097c9cd",
|
||||
"reference": "d3d66b8faa86ac57e1236d576ad003f73097c9cd",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/604de433dd3e1467ded9a92414b3561a812554c5",
|
||||
"reference": "604de433dd3e1467ded9a92414b3561a812554c5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -4218,7 +4219,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-17T06:16:24+00:00"
|
||||
"time": "2021-04-02T08:21:05+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/complexity",
|
||||
|
@ -4283,12 +4284,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/diff.git",
|
||||
"reference": "e81849c6dfbe34442b4685fa457fd6f012370e54"
|
||||
"reference": "3fa178cf5772d7a09bcfe01bfb7acc13edcf8aec"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/e81849c6dfbe34442b4685fa457fd6f012370e54",
|
||||
"reference": "e81849c6dfbe34442b4685fa457fd6f012370e54",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3fa178cf5772d7a09bcfe01bfb7acc13edcf8aec",
|
||||
"reference": "3fa178cf5772d7a09bcfe01bfb7acc13edcf8aec",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -4342,7 +4343,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-17T06:16:31+00:00"
|
||||
"time": "2021-04-02T08:21:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/environment",
|
||||
|
@ -4350,12 +4351,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/environment.git",
|
||||
"reference": "c25633688d84a9f8694989223479051b5a8a23e7"
|
||||
"reference": "1fe23c75ca20a9cfe5ef8af473c726f9ef7e9465"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/c25633688d84a9f8694989223479051b5a8a23e7",
|
||||
"reference": "c25633688d84a9f8694989223479051b5a8a23e7",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1fe23c75ca20a9cfe5ef8af473c726f9ef7e9465",
|
||||
"reference": "1fe23c75ca20a9cfe5ef8af473c726f9ef7e9465",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -4406,7 +4407,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-17T06:16:40+00:00"
|
||||
"time": "2021-04-02T08:21:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/exporter",
|
||||
|
@ -4414,12 +4415,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/exporter.git",
|
||||
"reference": "9119858d42f3963d01b737f029bb90f8464fd0ca"
|
||||
"reference": "31abe95278f9b406051b4a26faf2677fbcc01755"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/9119858d42f3963d01b737f029bb90f8464fd0ca",
|
||||
"reference": "9119858d42f3963d01b737f029bb90f8464fd0ca",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/31abe95278f9b406051b4a26faf2677fbcc01755",
|
||||
"reference": "31abe95278f9b406051b4a26faf2677fbcc01755",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -4484,7 +4485,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-17T06:16:48+00:00"
|
||||
"time": "2021-04-02T08:21:30+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/global-state",
|
||||
|
@ -4492,12 +4493,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/global-state.git",
|
||||
"reference": "fe610de5530e3d29007134f76ee8dc79581a607d"
|
||||
"reference": "8684de2d84cd6a819f5e22a1292cd3b2e1f26487"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/fe610de5530e3d29007134f76ee8dc79581a607d",
|
||||
"reference": "fe610de5530e3d29007134f76ee8dc79581a607d",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/8684de2d84cd6a819f5e22a1292cd3b2e1f26487",
|
||||
"reference": "8684de2d84cd6a819f5e22a1292cd3b2e1f26487",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -4549,7 +4550,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-17T06:16:56+00:00"
|
||||
"time": "2021-04-02T08:21:38+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/lines-of-code",
|
||||
|
@ -4614,12 +4615,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/object-enumerator.git",
|
||||
"reference": "01ab82e49081de59e2da70c351d5f698c77c33c5"
|
||||
"reference": "b331fc5975a2225e6b93c7e6cd9fce0a57f0fddc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/01ab82e49081de59e2da70c351d5f698c77c33c5",
|
||||
"reference": "01ab82e49081de59e2da70c351d5f698c77c33c5",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/b331fc5975a2225e6b93c7e6cd9fce0a57f0fddc",
|
||||
"reference": "b331fc5975a2225e6b93c7e6cd9fce0a57f0fddc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -4664,7 +4665,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-17T06:17:03+00:00"
|
||||
"time": "2021-04-02T08:21:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/object-reflector",
|
||||
|
@ -4672,12 +4673,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/object-reflector.git",
|
||||
"reference": "7ed67aee59862b40785138f0203e86f1fde1b93a"
|
||||
"reference": "297a334e3ae78670a7633e36569d7362bb7397bf"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/7ed67aee59862b40785138f0203e86f1fde1b93a",
|
||||
"reference": "7ed67aee59862b40785138f0203e86f1fde1b93a",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/297a334e3ae78670a7633e36569d7362bb7397bf",
|
||||
"reference": "297a334e3ae78670a7633e36569d7362bb7397bf",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -4720,7 +4721,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-17T06:17:11+00:00"
|
||||
"time": "2021-04-02T08:21:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/recursion-context",
|
||||
|
@ -4728,12 +4729,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/recursion-context.git",
|
||||
"reference": "249976376508ed7e83b6dc429cd883a44b2a3c51"
|
||||
"reference": "78526ace5bac7c10048020f0317c58fd310a14ec"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/249976376508ed7e83b6dc429cd883a44b2a3c51",
|
||||
"reference": "249976376508ed7e83b6dc429cd883a44b2a3c51",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/78526ace5bac7c10048020f0317c58fd310a14ec",
|
||||
"reference": "78526ace5bac7c10048020f0317c58fd310a14ec",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -4784,7 +4785,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-17T06:17:43+00:00"
|
||||
"time": "2021-04-02T08:22:30+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/resource-operations",
|
||||
|
@ -4848,12 +4849,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/type.git",
|
||||
"reference": "e02c851008e26557b4f1b4ffd139b71c96937b04"
|
||||
"reference": "17fc98bb3c75a02a1a99ffdd022e84ac6d22bd51"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/e02c851008e26557b4f1b4ffd139b71c96937b04",
|
||||
"reference": "e02c851008e26557b4f1b4ffd139b71c96937b04",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/17fc98bb3c75a02a1a99ffdd022e84ac6d22bd51",
|
||||
"reference": "17fc98bb3c75a02a1a99ffdd022e84ac6d22bd51",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -4897,7 +4898,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-17T06:17:51+00:00"
|
||||
"time": "2021-04-02T08:36:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/version",
|
||||
|
@ -4996,12 +4997,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/console.git",
|
||||
"reference": "5da8b675121f9f4419b7052caa0cc6118a3ccd47"
|
||||
"reference": "9a90698d4624b85a578007a00312338d3adecaf8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/5da8b675121f9f4419b7052caa0cc6118a3ccd47",
|
||||
"reference": "5da8b675121f9f4419b7052caa0cc6118a3ccd47",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/9a90698d4624b85a578007a00312338d3adecaf8",
|
||||
"reference": "9a90698d4624b85a578007a00312338d3adecaf8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -5087,7 +5088,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-23T14:20:07+00:00"
|
||||
"time": "2021-04-09T09:54:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/deprecation-contracts",
|
||||
|
@ -5575,12 +5576,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/service-contracts.git",
|
||||
"reference": "1309413986521646bb0ba91140afdc2a61ed8cfe"
|
||||
"reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/1309413986521646bb0ba91140afdc2a61ed8cfe",
|
||||
"reference": "1309413986521646bb0ba91140afdc2a61ed8cfe",
|
||||
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb",
|
||||
"reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -5647,7 +5648,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-23T23:28:01+00:00"
|
||||
"time": "2021-04-01T10:43:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/string",
|
||||
|
@ -5789,12 +5790,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/twigphp/Twig.git",
|
||||
"reference": "116bfb0bc9ec2a39db93431b7fe67144164d251e"
|
||||
"reference": "f7250c6ea6b6cdd724e25ce7c56e2a60006203cb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/116bfb0bc9ec2a39db93431b7fe67144164d251e",
|
||||
"reference": "116bfb0bc9ec2a39db93431b7fe67144164d251e",
|
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/f7250c6ea6b6cdd724e25ce7c56e2a60006203cb",
|
||||
"reference": "f7250c6ea6b6cdd724e25ce7c56e2a60006203cb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -5860,7 +5861,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-22T08:23:49+00:00"
|
||||
"time": "2021-04-10T08:17:25+00:00"
|
||||
},
|
||||
{
|
||||
"name": "vimeo/psalm",
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Tests\E2E\Services\Storage;
|
|||
|
||||
use CURLFile;
|
||||
use Tests\E2E\Client;
|
||||
use Utopia\Image\Image;
|
||||
|
||||
trait StorageBase
|
||||
{
|
||||
|
@ -73,25 +74,75 @@ trait StorageBase
|
|||
$this->assertEquals(200, $file2['headers']['status-code']);
|
||||
$this->assertEquals('image/png', $file2['headers']['content-type']);
|
||||
$this->assertNotEmpty($file2['body']);
|
||||
|
||||
$file3 = $this->client->call(Client::METHOD_GET, '/storage/files/' . $data['fileId'] . '/download', array_merge([
|
||||
|
||||
//new image preview features
|
||||
$file3 = $this->client->call(Client::METHOD_GET, '/storage/files/' . $data['fileId'] . '/preview', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
], $this->getHeaders()), [
|
||||
'width' => 300,
|
||||
'height' => 100,
|
||||
'borderRadius' => '50',
|
||||
'opacity' => '0.5',
|
||||
'output' => 'png',
|
||||
'rotation' => '45',
|
||||
]);
|
||||
|
||||
|
||||
$this->assertEquals(200, $file3['headers']['status-code']);
|
||||
$this->assertEquals('attachment; filename="logo.png"', $file3['headers']['content-disposition']);
|
||||
$this->assertEquals('image/png', $file3['headers']['content-type']);
|
||||
$this->assertNotEmpty($file3['body']);
|
||||
|
||||
$file4 = $this->client->call(Client::METHOD_GET, '/storage/files/' . $data['fileId'] . '/view', array_merge([
|
||||
$image = new \Imagick();
|
||||
$image->readImageBlob($file3['body']);
|
||||
$original = new \Imagick(__DIR__ . '/../../../resources/logo-after.png');
|
||||
|
||||
$this->assertEquals($image->getImageWidth(), $original->getImageWidth());
|
||||
$this->assertEquals($image->getImageHeight(), $original->getImageHeight());
|
||||
$this->assertEquals('PNG', $image->getImageFormat());
|
||||
|
||||
|
||||
$file4 = $this->client->call(Client::METHOD_GET, '/storage/files/' . $data['fileId'] . '/preview', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'width' => 200,
|
||||
'height' => 80,
|
||||
'borderWidth' => '5',
|
||||
'borderColor' => 'ff0000',
|
||||
'output' => 'jpg',
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $file4['headers']['status-code']);
|
||||
$this->assertEquals('image/jpeg', $file4['headers']['content-type']);
|
||||
$this->assertNotEmpty($file4['body']);
|
||||
|
||||
$image = new \Imagick();
|
||||
$image->readImageBlob($file4['body']);
|
||||
$original = new \Imagick(__DIR__ . '/../../../resources/logo-after.jpg');
|
||||
|
||||
$this->assertEquals($image->getImageWidth(), $original->getImageWidth());
|
||||
$this->assertEquals($image->getImageHeight(), $original->getImageHeight());
|
||||
$this->assertEquals('JPEG', $image->getImageFormat());
|
||||
|
||||
$file5 = $this->client->call(Client::METHOD_GET, '/storage/files/' . $data['fileId'] . '/download', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals(200, $file4['headers']['status-code']);
|
||||
$this->assertEquals('image/png', $file4['headers']['content-type']);
|
||||
$this->assertNotEmpty($file4['body']);
|
||||
$this->assertEquals(200, $file5['headers']['status-code']);
|
||||
$this->assertEquals('attachment; filename="logo.png"', $file5['headers']['content-disposition']);
|
||||
$this->assertEquals('image/png', $file5['headers']['content-type']);
|
||||
$this->assertNotEmpty($file5['body']);
|
||||
|
||||
$file6 = $this->client->call(Client::METHOD_GET, '/storage/files/' . $data['fileId'] . '/view', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals(200, $file6['headers']['status-code']);
|
||||
$this->assertEquals('image/png', $file6['headers']['content-type']);
|
||||
$this->assertNotEmpty($file6['body']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
|
|
BIN
tests/resources/file.png
Normal file
BIN
tests/resources/file.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
tests/resources/logo-after.jpg
Normal file
BIN
tests/resources/logo-after.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
tests/resources/logo-after.png
Normal file
BIN
tests/resources/logo-after.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
Loading…
Reference in a new issue