From c65d1a686b9e1f87932b95d9af77d154de00c241 Mon Sep 17 00:00:00 2001 From: drjdr <55947988+drjdr@users.noreply.github.com> Date: Sat, 19 Feb 2022 11:56:04 +0100 Subject: [PATCH 1/9] Add Laravel 9 support with support of old Laravel versions --- composer.json | 9 ++--- src/Storage/ChunkStorage.php | 71 ++++++++++++++++++++++-------------- 2 files changed, 47 insertions(+), 33 deletions(-) diff --git a/composer.json b/composer.json index 42c9362..6e73b7b 100644 --- a/composer.json +++ b/composer.json @@ -15,13 +15,12 @@ "test": "./vendor/bin/phpunit" }, "require": { - "illuminate/http": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0", - "illuminate/console": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0", - "illuminate/support": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0", - "illuminate/filesystem": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0" + "illuminate/http": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0 | ^9.0", + "illuminate/console": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0 | ^9.0", + "illuminate/support": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0 | ^9.0", + "illuminate/filesystem": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0 | ^9.0" }, "require-dev": { - "laravel/laravel": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0", "phpunit/phpunit": "5.7 | 6.0 | 7.0 | 7.5 | 8.4 | ^8.5 | ^9.3", "mockery/mockery": "^1.1.0 | ^1.3.0", "friendsofphp/php-cs-fixer": "^2.16.0", diff --git a/src/Storage/ChunkStorage.php b/src/Storage/ChunkStorage.php index aa9cc16..882a837 100644 --- a/src/Storage/ChunkStorage.php +++ b/src/Storage/ChunkStorage.php @@ -4,7 +4,9 @@ use Illuminate\Contracts\Filesystem\Filesystem as FilesystemContract; use Illuminate\Support\Collection; +use Illuminate\Filesystem\FilesystemAdapter; use League\Flysystem\Adapter\Local; +use League\Flysystem\Local\LocalFilesystemAdapter; use League\Flysystem\FilesystemInterface; use Pion\Laravel\ChunkUpload\ChunkFile; use Pion\Laravel\ChunkUpload\Config\AbstractConfig; @@ -28,52 +30,61 @@ public static function storage() * @var AbstractConfig */ protected $config; - /** * The disk that holds the chunk files. * - * @var FilesystemAdapter + * @var FilesystemContract|FilesystemAdapter */ protected $disk; - /** - * @var Local + * @var Local|LocalFilesystemAdapter */ protected $diskAdapter; + protected $isLocalDisk; /** - * Is provided disk a local drive. - * - * @var bool + * @var */ - protected $isLocalDisk; + protected $usingDeprecatedLaravel; /** - * ChunkStorage constructor. - * - * @param FilesystemContract $disk the desired disk for chunk storage - * @param AbstractConfig $config + * @param FilesystemAdapter|FilesystemContract $disk the desired disk for chunk storage + * @param AbstractConfig $config */ - public function __construct(FilesystemContract $disk, $config) + public function __construct($disk, $config) { // save the config $this->config = $config; - - // cache the storage path + $this->usingDeprecatedLaravel = class_exists(LocalFilesystemAdapter::class) === false; $this->disk = $disk; - $driver = $this->driver(); + if ($this->usingDeprecatedLaravel === false) { - // try to get the adapter - if (!method_exists($driver, 'getAdapter')) { - throw new RuntimeException('FileSystem driver must have an adapter implemented'); - } + // try to get the adapter + if (!method_exists($this->disk, 'getAdapter')) { + throw new RuntimeException('FileSystem driver must have an adapter implemented'); + } + + // get the disk adapter + $this->diskAdapter = $this->disk->getAdapter(); - // get the disk adapter - $this->diskAdapter = $driver->getAdapter(); + // check if its local adapter + $this->isLocalDisk = $this->diskAdapter instanceof LocalFilesystemAdapter; + } else { + $driver = $this->driver(); + + // try to get the adapter + if (!method_exists($driver, 'getAdapter')) { + throw new RuntimeException('FileSystem driver must have an adapter implemented'); + } + + // get the disk adapter + $this->diskAdapter = $driver->getAdapter(); + + // check if its local adapter + $this->isLocalDisk = $this->diskAdapter instanceof Local; + } - // check if its local adapter - $this->isLocalDisk = $this->diskAdapter instanceof Local; } /** @@ -85,10 +96,14 @@ public function __construct(FilesystemContract $disk, $config) */ public function getDiskPathPrefix() { - if ($this->isLocalDisk) { + if ($this->usingDeprecatedLaravel === true && $this->isLocalDisk) { return $this->diskAdapter->getPathPrefix(); } + if ($this->isLocalDisk) { + return $this->disk->path(''); + } + throw new RuntimeException('The full path is not supported on current disk - local adapter supported only'); } @@ -99,7 +114,7 @@ public function getDiskPathPrefix() */ public function directory() { - return $this->config->chunksStorageDirectory().'/'; + return $this->config->chunksStorageDirectory() . '/'; } /** @@ -119,7 +134,7 @@ public function files($rejectClosure = null) return $filesCollection->reject(function ($file) use ($rejectClosure) { // ensure the file ends with allowed extension - $shouldReject = !preg_match('/.'.self::CHUNK_EXTENSION.'$/', $file); + $shouldReject = !preg_match('/.' . self::CHUNK_EXTENSION . '$/', $file); if ($shouldReject) { return true; } @@ -182,7 +197,7 @@ public function disk() /** * Returns the driver. * - * @return FilesystemInterface + * @return FilesystemOperator|FilesystemInterface */ public function driver() { From 37b20f1c8d4e8676f733ca98ef6d0309cbf94e74 Mon Sep 17 00:00:00 2001 From: Martin Kluska Date: Mon, 21 Mar 2022 13:43:48 +0100 Subject: [PATCH 2/9] Update readme compatibility map --- readme.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/readme.md b/readme.md index 45b9530..fd5ded3 100644 --- a/readme.md +++ b/readme.md @@ -67,15 +67,17 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for how to contribute changes. All contri ## Compatibility -* 7.* (last tested on v7.16.1) -* 6.* (last tested on v6.18.20) -* 5.8.* (last tested on v5.8.38) -* 5.7.* (last tested on v5.7.29) -* 5.6.* (last tested on v5.6.40) -* 5.5.* (last tested on v5.5.49) -* 5.4.* (last tested on v5.4.36) -* 5.3.* (last tested on v5.3.31) -* 5.2.* (last tested on v5.2.45) +> Laravel 5/6 should be still supported but we are not testing them via automation sccripts + +| Version | PHP | +| ------- | ----------- | +| 9.* | 8.1-node-17 | +| 9.* | 8.0-node-17 | +| 8.* | 8.1-node-17 | +| 8.* | 8.0-node-17 | +| 8.* | 7.4-node-17 | +| 7.* | 7.4-node-17 | + ## Copyright and License From a006ff5c4e5cf6621e420faee2a2bac018815be0 Mon Sep 17 00:00:00 2001 From: Paul Klimov Date: Tue, 15 Feb 2022 17:09:49 +0200 Subject: [PATCH 3/9] switch to GitHub actions --- .gitattributes | 17 ++++++---- .github/ISSUE_TEMPLATE.md | 14 ++++++++ .github/PULL_REQUEST_TEMPLATE.md | 7 ++++ .github/workflows/build.yml | 32 +++++++++++++++++++ .travis.yml | 11 ------- config/chunk-upload.php | 3 ++ phpunit.xml => phpunit.xml.dist | 0 readme.md | 2 +- .../ChunkUploadServiceProviderMockTest.php | 6 +--- 9 files changed, 69 insertions(+), 23 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/build.yml delete mode 100644 .travis.yml rename phpunit.xml => phpunit.xml.dist (100%) diff --git a/.gitattributes b/.gitattributes index 87ff7d7..3d7b658 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,11 @@ -tests -travis.yml -.php_cs -.phplint.yml -phpunit.xml -CODE_OF_CONDUCT.md \ No newline at end of file +# Ignore all test and documentation for archive +/.github export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.scrutinizer.yml export-ignore +/phpunit.xml.dist export-ignore +/tests export-ignore +/docs export-ignore +/.php_cs export-ignore +/.phplint.yml export-ignore +/CODE_OF_CONDUCT.md export-ignore \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..ebddba8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,14 @@ +### What steps will reproduce the problem? + +### What is the expected result? + +### What do you get instead? + +### Additional info + +| Q | A +| ------------------------- | --- +| This Package Version | 1.?.? +| Laravel Framework Version | 9.?.? +| PHP version | +| Operating system | diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..f4af2f3 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,7 @@ +| Q | A +| ------------- | --- +| Is bugfix? | ✔️/❌ +| New feature? | ✔️/❌ +| Breaks BC? | ✔️/❌ +| Tests pass? | ✔️/❌ +| Fixed issues | comma-separated list of tickets # fixed by the PR, if any \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..834c8e0 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,32 @@ +name: build + +on: [push, pull_request] + +jobs: + phpunit: + name: PHP ${{ matrix.php }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + php: ['7.2', '7.3', '7.4', '8.0', '8.1'] + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: mbstring + tools: composer:v2 + coverage: none + + - name: Install dependencies + run: | + composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + + - name: Run unit tests + run: vendor/bin/phpunit --verbose --colors=always \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b12cbf5..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: php -php: - - '7.2' - - '7.3' - - '7.4' -os: - - linux - -before_script: composer install --dev - -script: ./vendor/phpunit/phpunit/phpunit --configuration phpunit.xml diff --git a/config/chunk-upload.php b/config/chunk-upload.php index 575f826..422fa78 100644 --- a/config/chunk-upload.php +++ b/config/chunk-upload.php @@ -1,4 +1,7 @@ app = Mockery::mock(\Illuminate\Contracts\Container\Container::class); $this->config = Mockery::mock(Repository::class); From e1ffe87e8a50a6a8cf8204c6afd46f6df99083e6 Mon Sep 17 00:00:00 2001 From: shivank44 <52524465+shivank44@users.noreply.github.com> Date: Wed, 31 Aug 2022 13:00:45 +0530 Subject: [PATCH 4/9] Fix issue for file having large name (#125) --- src/Handler/ResumableJSUploadHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Handler/ResumableJSUploadHandler.php b/src/Handler/ResumableJSUploadHandler.php index 59f79f2..7a70ae9 100644 --- a/src/Handler/ResumableJSUploadHandler.php +++ b/src/Handler/ResumableJSUploadHandler.php @@ -43,7 +43,7 @@ public function __construct(Request $request, $file, $config) */ public function getChunkFileName() { - return $this->createChunkFileName($this->fileUuid, $this->getCurrentChunk()); + return $this->createChunkFileName(substr($this->fileUuid,0,40), $this->getCurrentChunk()); } /** From a4037fcaf6b82ff4b4f58387fb7dce463de4c65f Mon Sep 17 00:00:00 2001 From: Ronaldo Cesar Paggi Date: Wed, 12 Oct 2022 11:01:42 -0300 Subject: [PATCH 5/9] Update Dropzone repository url --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index e1c31cb..eb0fce3 100644 --- a/readme.md +++ b/readme.md @@ -43,7 +43,7 @@ Setup consists of 3 steps: | Library | Wiki | single & chunk upload | simultaneous uploads | In [example project](https://github.com/pionl/laravel-chunk-upload-example) | Author | |---- |----|----|----| ---- | ---- | | [resumable.js](https://github.com/23/resumable.js) | [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki/resumable-js) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | [@pionl](https://github.com/pionl) | -| [DropZone](https://gitlab.com/meno/dropzone/) | [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki/dropzone) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | [@pionl](https://github.com/pionl) | +| [DropZone](https://github.com/dropzone/dropzone) | [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki/dropzone) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | [@pionl](https://github.com/pionl) | | [jQuery-File-Upload](https://github.com/blueimp/jQuery-File-Upload) | [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki/jquery-file-upload) | :heavy_check_mark: | :heavy_multiplication_x: | :heavy_check_mark: | [@pionl](https://github.com/pionl) | | [Plupload](https://github.com/moxiecode/plupload) | [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki/plupload) | :heavy_check_mark: | :heavy_multiplication_x: | :heavy_multiplication_x: | [@pionl](https://github.com/pionl) | | [simple uploader](https://github.com/simple-uploader) | :heavy_multiplication_x: | :heavy_check_mark: | :heavy_multiplication_x: | :heavy_multiplication_x: | [@dyktek](https://github.com/dyktek) | From 49c84c699c940de4cc18d34a987e169e08802a30 Mon Sep 17 00:00:00 2001 From: Vedmant Date: Tue, 1 Nov 2022 17:10:31 -0500 Subject: [PATCH 6/9] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index eb0fce3..8766c3a 100644 --- a/readme.md +++ b/readme.md @@ -8,7 +8,7 @@ ## Introduction -> Supports Laravel from 5.2 to 7 (covered by integration tests on all versions). +> Supports Laravel from 5.2 to 9 (covered by integration tests for 7/8/9 versions). Easy to use service/library for chunked upload with supporting multiple JS libraries on top of Laravel's file upload with low memory footprint in mind. From dcf5cf42059910242c31fc34d0ea147d07478473 Mon Sep 17 00:00:00 2001 From: Martin Kluska Date: Wed, 15 Mar 2023 22:02:42 +0100 Subject: [PATCH 7/9] Add Laravel 10 support + upgrade to PHPUnit 10 --- .gitignore | 1 + composer.json | 10 +++++----- phpunit.xml.dist | 30 +++++++++++------------------- readme.md | 14 ++++++-------- 4 files changed, 23 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index b9b19b9..6473415 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ composer.lock /build .phpunit.result.cache .php_cs.cache +/.phpunit.cache diff --git a/composer.json b/composer.json index 6e73b7b..b0ecb74 100644 --- a/composer.json +++ b/composer.json @@ -15,13 +15,13 @@ "test": "./vendor/bin/phpunit" }, "require": { - "illuminate/http": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0 | ^9.0", - "illuminate/console": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0 | ^9.0", - "illuminate/support": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0 | ^9.0", - "illuminate/filesystem": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0 | ^9.0" + "illuminate/http": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0 | ^9.0 | ^10.0", + "illuminate/console": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0 | ^9.0 | ^10.0", + "illuminate/support": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0 | ^9.0 | ^10.0", + "illuminate/filesystem": "5.2 - 5.8 | ^6.0 | ^7.0 | ^8.0 | ^9.0 | ^10.0" }, "require-dev": { - "phpunit/phpunit": "5.7 | 6.0 | 7.0 | 7.5 | 8.4 | ^8.5 | ^9.3", + "phpunit/phpunit": "5.7 | 6.0 | 7.0 | 7.5 | 8.4 | ^8.5 | ^9.3 | ^10.0", "mockery/mockery": "^1.1.0 | ^1.3.0", "friendsofphp/php-cs-fixer": "^2.16.0", "overtrue/phplint": "^1.1 | ^2.0" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index da32b83..6d07324 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,21 +1,13 @@ - - - - ./tests/ - - - - - src/ - - + + + + src/ + + + + + ./tests/ + + diff --git a/readme.md b/readme.md index 8766c3a..ccc05c8 100644 --- a/readme.md +++ b/readme.md @@ -69,14 +69,12 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for how to contribute changes. All contri > Laravel 5/6 should be still supported but we are not testing them via automation sccripts -| Version | PHP | -| ------- | ----------- | -| 9.* | 8.1-node-17 | -| 9.* | 8.0-node-17 | -| 8.* | 8.1-node-17 | -| 8.* | 8.0-node-17 | -| 8.* | 7.4-node-17 | -| 7.* | 7.4-node-17 | +| Version | PHP | +|---------|---------------| +| 10.* | 8.1, 8.2 | +| 9.* | 8.0, 8.1 | +| 8.* | 7.4, 8.0, 8.1 | +| 7.* | 7.4 | From 0564c77e451650408bd59090f3686e9bab781fb9 Mon Sep 17 00:00:00 2001 From: Martin Kluska Date: Sat, 18 Mar 2023 19:02:34 +0100 Subject: [PATCH 8/9] Run tests also on PHP 8.2 --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 834c8e0..9292b34 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - php: ['7.2', '7.3', '7.4', '8.0', '8.1'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] steps: - name: Checkout @@ -29,4 +29,4 @@ jobs: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - name: Run unit tests - run: vendor/bin/phpunit --verbose --colors=always \ No newline at end of file + run: vendor/bin/phpunit --colors=always From 98c56033b33fbd87f841774e2c778d9f16163c8f Mon Sep 17 00:00:00 2001 From: Zane Oliver Date: Mon, 18 Mar 2024 11:47:40 -0600 Subject: [PATCH 9/9] migrate unit test config --- .gitignore | 1 + phpunit.xml.dist | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 6473415..b1f8a02 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ composer.lock .phpunit.result.cache .php_cs.cache /.phpunit.cache +phpunit.xml.dist.bak diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 6d07324..079d5be 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,13 +1,13 @@ - - - - src/ - - + ./tests/ + + + src/ + +