From e34a6f988ba78e0e31a6364319b73aea9669f818 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Thu, 21 Oct 2021 10:25:12 -0400 Subject: [PATCH 01/11] Update redis to 6.2 from 6.0 --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2a86fc575e..7f1e11e825 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -464,7 +464,7 @@ services: # - SMARTHOST_PORT=587 redis: - image: redis:6.0-alpine + image: redis:6.2-alpine container_name: appwrite-redis networks: - appwrite From 12094126b43a330ee6c7c91cc8784a2636166911 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Thu, 21 Oct 2021 10:25:32 -0400 Subject: [PATCH 02/11] Update influxdb and telegraf with new builds --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7f1e11e825..e8214bf27b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -480,7 +480,7 @@ services: # - appwrite-uploads:/storage/uploads influxdb: - image: appwrite/influxdb:1.0.0 + image: kodumbeats/appwrite-influxdb:1.8.10 container_name: appwrite-influxdb networks: - appwrite @@ -488,7 +488,7 @@ services: - appwrite-influxdb:/var/lib/influxdb:rw telegraf: - image: appwrite/telegraf:1.2.0 + image: kodumbeats/appwrite-telegraf:1.20.2 container_name: appwrite-telegraf networks: - appwrite From fb24335876134d0abc47c1274e9de5c97077a700 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 22 Oct 2021 10:32:45 +0200 Subject: [PATCH 03/11] feat(sdk): swift 0.1.1 --- app/config/platforms.php | 2 +- composer.json | 2 +- composer.lock | 238 +++++++++++++++++++++------------------ 3 files changed, 131 insertions(+), 111 deletions(-) diff --git a/app/config/platforms.php b/app/config/platforms.php index 16f6cf42ba..d14e9bfa5a 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -81,7 +81,7 @@ return [ [ 'key' => 'apple', 'name' => 'Apple', - 'version' => '0.1.0', + 'version' => '0.1.1', 'url' => 'https://github.com/appwrite/sdk-for-apple', 'package' => 'https://github.com/appwrite/sdk-for-apple', 'enabled' => true, diff --git a/composer.json b/composer.json index 304cc03264..328258037b 100644 --- a/composer.json +++ b/composer.json @@ -64,7 +64,7 @@ "slickdeals/statsd": "3.1.0" }, "require-dev": { - "appwrite/sdk-generator": "dev-feat-swift-templates", + "appwrite/sdk-generator": "0.16.0", "phpunit/phpunit": "9.5.6", "swoole/ide-helper": "4.6.7", "textalk/websocket": "1.5.2", diff --git a/composer.lock b/composer.lock index 45d1525e8f..db469e9e8c 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "6658bcb6a570300242ac1d227052f1bf", + "content-hash": "c5e9d3dbc8964f01310bb249b654fb7a", "packages": [ { "name": "adhocore/jwt", @@ -115,16 +115,16 @@ }, { "name": "appwrite/php-runtimes", - "version": "0.6.0", + "version": "0.6.1", "source": { "type": "git", "url": "https://github.com/appwrite/php-runtimes.git", - "reference": "b4ca9786e6012c99db30baa752b55d935294ac5c" + "reference": "a42434de2fbd60818244c1a9b2ac0429ad0ef9ee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/php-runtimes/zipball/b4ca9786e6012c99db30baa752b55d935294ac5c", - "reference": "b4ca9786e6012c99db30baa752b55d935294ac5c", + "url": "https://api.github.com/repos/appwrite/php-runtimes/zipball/a42434de2fbd60818244c1a9b2ac0429ad0ef9ee", + "reference": "a42434de2fbd60818244c1a9b2ac0429ad0ef9ee", "shasum": "" }, "require": { @@ -164,9 +164,9 @@ ], "support": { "issues": "https://github.com/appwrite/php-runtimes/issues", - "source": "https://github.com/appwrite/php-runtimes/tree/0.6.0" + "source": "https://github.com/appwrite/php-runtimes/tree/0.6.1" }, - "time": "2021-10-06T13:26:31+00:00" + "time": "2021-10-21T11:32:25+00:00" }, { "name": "chillerlan/php-qrcode", @@ -416,24 +416,25 @@ }, { "name": "guzzlehttp/guzzle", - "version": "7.3.0", + "version": "7.4.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "7008573787b430c1c1f650e3722d9bba59967628" + "reference": "868b3571a039f0ebc11ac8f344f4080babe2cb94" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/7008573787b430c1c1f650e3722d9bba59967628", - "reference": "7008573787b430c1c1f650e3722d9bba59967628", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/868b3571a039f0ebc11ac8f344f4080babe2cb94", + "reference": "868b3571a039f0ebc11ac8f344f4080babe2cb94", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^1.4", - "guzzlehttp/psr7": "^1.7 || ^2.0", + "guzzlehttp/promises": "^1.5", + "guzzlehttp/psr7": "^1.8.3 || ^2.1", "php": "^7.2.5 || ^8.0", - "psr/http-client": "^1.0" + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2" }, "provide": { "psr/http-client-implementation": "1.0" @@ -443,7 +444,7 @@ "ext-curl": "*", "php-http/client-integration-tests": "^3.0", "phpunit/phpunit": "^8.5.5 || ^9.3.5", - "psr/log": "^1.1" + "psr/log": "^1.1 || ^2.0 || ^3.0" }, "suggest": { "ext-curl": "Required for CURL handler support", @@ -453,7 +454,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "7.3-dev" + "dev-master": "7.4-dev" } }, "autoload": { @@ -469,19 +470,43 @@ "MIT" ], "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, { "name": "Michael Dowling", "email": "mtdowling@gmail.com", "homepage": "https://github.com/mtdowling" }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, { "name": "Márk Sági-Kazár", "email": "mark.sagikazar@gmail.com", - "homepage": "https://sagikazarmark.hu" + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" } ], "description": "Guzzle is a PHP HTTP client library", - "homepage": "http://guzzlephp.org/", "keywords": [ "client", "curl", @@ -495,7 +520,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.3.0" + "source": "https://github.com/guzzle/guzzle/tree/7.4.0" }, "funding": [ { @@ -507,15 +532,11 @@ "type": "github" }, { - "url": "https://github.com/alexeyshockov", - "type": "github" - }, - { - "url": "https://github.com/gmponos", - "type": "github" + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" } ], - "time": "2021-03-23T11:33:13+00:00" + "time": "2021-10-18T09:52:00+00:00" }, { "name": "guzzlehttp/promises", @@ -1372,6 +1393,73 @@ }, "time": "2021-06-04T20:33:46+00:00" }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-03-23T23:28:01+00:00" + }, { "name": "symfony/polyfill-ctype", "version": "v1.23.0", @@ -2582,16 +2670,16 @@ }, { "name": "appwrite/sdk-generator", - "version": "dev-feat-swift-templates", + "version": "0.16.0", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "0fe34f984cded746a13b4c5dacb6c008f72d6897" + "reference": "5a57afe89ded393a3eca8d9ba96b8e2c479f2601" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/0fe34f984cded746a13b4c5dacb6c008f72d6897", - "reference": "0fe34f984cded746a13b4c5dacb6c008f72d6897", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/5a57afe89ded393a3eca8d9ba96b8e2c479f2601", + "reference": "5a57afe89ded393a3eca8d9ba96b8e2c479f2601", "shasum": "" }, "require": { @@ -2625,9 +2713,9 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/feat-swift-templates" + "source": "https://github.com/appwrite/sdk-generator/tree/0.16.0" }, - "time": "2021-10-18T08:23:10+00:00" + "time": "2021-10-21T06:49:55+00:00" }, { "name": "composer/package-versions-deprecated", @@ -3569,16 +3657,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.2.2", + "version": "5.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556" + "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556", - "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", + "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", "shasum": "" }, "require": { @@ -3589,7 +3677,8 @@ "webmozart/assert": "^1.9.1" }, "require-dev": { - "mockery/mockery": "~1.3.2" + "mockery/mockery": "~1.3.2", + "psalm/phar": "^4.8" }, "type": "library", "extra": { @@ -3619,9 +3708,9 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" }, - "time": "2020-09-03T19:13:55+00:00" + "time": "2021-10-19T17:43:47+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -5325,73 +5414,6 @@ ], "time": "2021-08-25T20:02:16+00:00" }, - { - "name": "symfony/deprecation-contracts", - "version": "v2.4.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627", - "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.4-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.4.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-03-23T23:28:01+00:00" - }, { "name": "symfony/polyfill-intl-grapheme", "version": "v1.23.1", @@ -6297,9 +6319,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "appwrite/sdk-generator": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { From 5dfdf3b3acca6ef4dc76ccfb48867b9051588772 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Fri, 22 Oct 2021 16:06:23 +0545 Subject: [PATCH 04/11] wip --- app/controllers/mock.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/mock.php b/app/controllers/mock.php index d4076547e0..306ee61b5f 100644 --- a/app/controllers/mock.php +++ b/app/controllers/mock.php @@ -237,6 +237,10 @@ App::post('/v1/mock/tests/general/upload') ->action(function ($x, $y, $z, $file, $request) { /** @var Utopia\Swoole\Request $request */ + // support multipart upload + // validate md5 for each chunk + // validate individual chunk and chunk size + $file = $request->getFiles('file'); $file['tmp_name'] = (\is_array($file['tmp_name'])) ? $file['tmp_name'] : [$file['tmp_name']]; $file['name'] = (\is_array($file['name'])) ? $file['name'] : [$file['name']]; From e922fd66421c146b7cbf92f087b01471fdd1c8d0 Mon Sep 17 00:00:00 2001 From: Baishakhi Chakraborty Date: Fri, 22 Oct 2021 23:57:58 +0530 Subject: [PATCH 05/11] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e4d50bf529..98f6e9824a 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ docker run -it --rm , appwrite/appwrite:0.11.0 ``` -Once the Docker installation completes, go to http://localhost to access the Appwrite console from your browser. Please note that on non-linux native hosts, the server might take a few minutes to start after installation completes. +Once the Docker installation completes, go to http://localhost to access the Appwrite console from your browser. Please note that on non-Linux native hosts, the server might take a few minutes to start after installation completes. For advanced production and custom installation, check out our Docker [environment variables](https://appwrite.io/docs/environment-variables) docs. You can also use our public [docker-compose.yml](https://gist.github.com/eldadfux/977869ff6bdd7312adfd4e629ee15cc5#file-docker-compose-yml) file to manually set up an environment. @@ -94,7 +94,7 @@ If you are upgrading your Appwrite server from an older version, you should use ## Getting Started -Getting started with Appwrite is as easy as creating a new project, choosing your platform, and integrating its SDK in your code. You can easily get started with your platform of choice by reading one of our Getting Started tutorials. +Getting started with Appwrite is as easy as creating a new project, choosing your platform, and integrating its SDK into your code. You can easily get started with your platform of choice by reading one of our Getting Started tutorials. * [Getting Started for Web](https://appwrite.io/docs/getting-started-for-web) * [Getting Started for Flutter](https://appwrite.io/docs/getting-started-for-flutter) From d3942cd7a24d0199297b574e97f00e643b0ef51e Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Fri, 22 Oct 2021 14:52:31 -0400 Subject: [PATCH 06/11] Use appwrite-built telegraf/influx images --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e8214bf27b..d79eee2ea1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -480,7 +480,7 @@ services: # - appwrite-uploads:/storage/uploads influxdb: - image: kodumbeats/appwrite-influxdb:1.8.10 + image: appwrite/influxdb:1.4.0 container_name: appwrite-influxdb networks: - appwrite @@ -488,7 +488,7 @@ services: - appwrite-influxdb:/var/lib/influxdb:rw telegraf: - image: kodumbeats/appwrite-telegraf:1.20.2 + image: appwrite/telegraf:1.3.0 container_name: appwrite-telegraf networks: - appwrite From cf9e31a1de6f52369d39c168dee0749421cec1c2 Mon Sep 17 00:00:00 2001 From: "Eldad A. Fux" Date: Sun, 24 Oct 2021 19:25:09 +0300 Subject: [PATCH 07/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 98f6e9824a..09a6eea448 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ Below is a list of currently supported platforms and languages. If you wish to h #### Server * ✅   [NodeJS](https://github.com/appwrite/sdk-for-node) (Maintained by the Appwrite Team) * ✅   [PHP](https://github.com/appwrite/sdk-for-php) (Maintained by the Appwrite Team) -* ✅   [Dart](https://github.com/appwrite/sdk-for-dart) - **Beta** (Maintained by the Appwrite Team) +* ✅   [Dart](https://github.com/appwrite/sdk-for-dart) - (Maintained by the Appwrite Team) * ✅   [Deno](https://github.com/appwrite/sdk-for-deno) - **Beta** (Maintained by the Appwrite Team) * ✅   [Ruby](https://github.com/appwrite/sdk-for-ruby) (Maintained by the Appwrite Team) * ✅   [Python](https://github.com/appwrite/sdk-for-python) (Maintained by the Appwrite Team) From cc4ef95cc04001d9a463c8f526530ebd00404a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Santilio?= Date: Sun, 31 Oct 2021 12:01:20 +0100 Subject: [PATCH 08/11] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 09a6eea448..fcd2a29c96 100644 --- a/README.md +++ b/README.md @@ -139,8 +139,9 @@ Below is a list of currently supported platforms and languages. If you wish to h * ✅   [.NET](https://github.com/appwrite/sdk-for-dotnet) - **Experimental** (Maintained by the Appwrite Team) #### Community -* ✅   [Appcelerator Titanium](https://github.com/m1ga/ti.appwrite) (Maintained by [Michael Gangolf](https://github.com/m1ga/)) - +* ✅   [Appcelerator Titanium](https://github.com/m1ga/ti.appwrite) (Maintained by [Michael Gangolf](https://github.com/m1ga/)) +* ✅   [Godot Engine](https://github.com/m1ga/ti.appwrite) (Maintained by [fenix-hub @GodotNuts](https://github.com/GodotNuts/appwrite-sdk/)) + Looking for more SDKs? - Help us by contributing a pull request to our [SDK Generator](https://github.com/appwrite/sdk-generator)! ## Contributing From 410081bf116e45f5212690c5d2434c7dd9f3bec8 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 2 Nov 2021 11:17:02 +0545 Subject: [PATCH 09/11] some tests to validate mock tests --- app/controllers/mock.php | 77 ++++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 19 deletions(-) diff --git a/app/controllers/mock.php b/app/controllers/mock.php index 306ee61b5f..86f25b6e51 100644 --- a/app/controllers/mock.php +++ b/app/controllers/mock.php @@ -234,33 +234,72 @@ App::post('/v1/mock/tests/general/upload') ->param('z', null, new ArrayList(new Text(256)), 'Sample array param') ->param('file', [], new File(), 'Sample file param', false) ->inject('request') - ->action(function ($x, $y, $z, $file, $request) { + ->inject('response') + ->action(function ($x, $y, $z, $file, $request, $response) { /** @var Utopia\Swoole\Request $request */ + /** @var Utopia\Swoole\Response $response */ - // support multipart upload - // validate md5 for each chunk - // validate individual chunk and chunk size - $file = $request->getFiles('file'); - $file['tmp_name'] = (\is_array($file['tmp_name'])) ? $file['tmp_name'] : [$file['tmp_name']]; - $file['name'] = (\is_array($file['name'])) ? $file['name'] : [$file['name']]; - $file['size'] = (\is_array($file['size'])) ? $file['size'] : [$file['size']]; + + $contentRange = $request->getHeader('content-range'); + if(!empty($contentRange)) { + $start = $request->getContentRangeStart(); + $end = $request->getContentRangeEnd(); + $size = $request->getContentRangeSize(); + $id = $request->getHeader('x-appwrite-id', ''); + $file['size'] = (\is_array($file['size'])) ? $file['size'] : [$file['size']]; - foreach ($file['name'] as $i => $name) { - if ($name !== 'file.png') { - throw new Exception('Wrong file name', 400); + if(is_null($start) || is_null($end) || is_null($size)) { + throw new Exception('Invalid content-range header', 400); } - } - foreach ($file['size'] as $i => $size) { - if ($size !== 38756) { - throw new Exception('Wrong file size', 400); + if($start > $end || $end > $size) { + throw new Exception('Invalid content-range header', 400); } - } - foreach ($file['tmp_name'] as $i => $tmpName) { - if (\md5(\file_get_contents($tmpName)) !== 'd80e7e6999a3eb2ae0d631a96fe135a4') { - throw new Exception('Wrong file uploaded', 400); + if($start === 0 && !empty($id)) { + throw new Exception('First chunked request cannot have id header', 400); + } + + if($start !== 0 && $id !== 'newfileid') { + throw new Exception('All chunked request must have id header (except first)', 400); + } + + if($end !== $size && $end-$start !== 5*1024*1024) { + throw new Exception('Chunk size must be 5MB (except last chunk)', 400); + } + + foreach ($file['size'] as $i => $sz) { + if ($end !== $size && $sz !== 5*1024*1024) { + throw new Exception('Wrong chunk size', 400); + } + + if($sz > 5*1024*1024) { + throw new Exception('Chunk size must be 5MB or less', 400); + } + } + $response->json(['$id'=> 'newfileid']); + } else { + $file['tmp_name'] = (\is_array($file['tmp_name'])) ? $file['tmp_name'] : [$file['tmp_name']]; + $file['name'] = (\is_array($file['name'])) ? $file['name'] : [$file['name']]; + $file['size'] = (\is_array($file['size'])) ? $file['size'] : [$file['size']]; + + foreach ($file['name'] as $i => $name) { + if ($name !== 'file.png') { + throw new Exception('Wrong file name', 400); + } + } + + foreach ($file['size'] as $i => $size) { + if ($size !== 38756) { + throw new Exception('Wrong file size', 400); + } + } + + foreach ($file['tmp_name'] as $i => $tmpName) { + if (\md5(\file_get_contents($tmpName)) !== 'd80e7e6999a3eb2ae0d631a96fe135a4') { + throw new Exception('Wrong file uploaded', 400); + } } } }); From cff399530075b9215f6521effb003589eed36dcf Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 2 Nov 2021 14:44:26 +0545 Subject: [PATCH 10/11] fix response --- app/controllers/mock.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/mock.php b/app/controllers/mock.php index 86f25b6e51..6f24f055e8 100644 --- a/app/controllers/mock.php +++ b/app/controllers/mock.php @@ -249,6 +249,8 @@ App::post('/v1/mock/tests/general/upload') $id = $request->getHeader('x-appwrite-id', ''); $file['size'] = (\is_array($file['size'])) ? $file['size'] : [$file['size']]; + var_dump($id); + if(is_null($start) || is_null($end) || is_null($size)) { throw new Exception('Invalid content-range header', 400); } @@ -265,7 +267,7 @@ App::post('/v1/mock/tests/general/upload') throw new Exception('All chunked request must have id header (except first)', 400); } - if($end !== $size && $end-$start !== 5*1024*1024) { + if($end !== $size && $end-$start+1 !== 5*1024*1024) { throw new Exception('Chunk size must be 5MB (except last chunk)', 400); } @@ -278,7 +280,9 @@ App::post('/v1/mock/tests/general/upload') throw new Exception('Chunk size must be 5MB or less', 400); } } - $response->json(['$id'=> 'newfileid']); + if($end !== $size) { + $response->json(['$id'=> 'newfileid']); + } } else { $file['tmp_name'] = (\is_array($file['tmp_name'])) ? $file['tmp_name'] : [$file['tmp_name']]; $file['name'] = (\is_array($file['name'])) ? $file['name'] : [$file['name']]; From 27cc105325c0819ac4acadf9ecb06537f1b4aacf Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 2 Nov 2021 15:04:18 +0545 Subject: [PATCH 11/11] remove leftover dump --- app/controllers/mock.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/controllers/mock.php b/app/controllers/mock.php index 6f24f055e8..ffffff1ad6 100644 --- a/app/controllers/mock.php +++ b/app/controllers/mock.php @@ -249,8 +249,6 @@ App::post('/v1/mock/tests/general/upload') $id = $request->getHeader('x-appwrite-id', ''); $file['size'] = (\is_array($file['size'])) ? $file['size'] : [$file['size']]; - var_dump($id); - if(is_null($start) || is_null($end) || is_null($size)) { throw new Exception('Invalid content-range header', 400); }