Skip to content

L9 support #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "pion/laravel-chunk-upload",
"name": "drjdr/laravel-chunk-upload",
"description": "Service for chunked upload with several js providers",
"license": "MIT",
"authors": [
Expand All @@ -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",
Expand Down
43 changes: 9 additions & 34 deletions src/Storage/ChunkStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

use Illuminate\Contracts\Filesystem\Filesystem as FilesystemContract;
use Illuminate\Support\Collection;
use League\Flysystem\Adapter\Local;
use Illuminate\Filesystem\FilesystemAdapter;
use League\Flysystem\Local\LocalFilesystemAdapter;
use League\Flysystem\FilesystemInterface;
use Pion\Laravel\ChunkUpload\ChunkFile;
use Pion\Laravel\ChunkUpload\Config\AbstractConfig;
Expand All @@ -14,66 +15,40 @@ class ChunkStorage
{
const CHUNK_EXTENSION = 'part';

/**
* Returns the application instance of the chunk storage.
*
* @return ChunkStorage
*/
public static function storage()
{
return app(self::class);
}

/**
* @var AbstractConfig
*/
protected $config;

/**
* The disk that holds the chunk files.
*
* @var FilesystemAdapter
*/
protected $disk;

/**
* @var Local
*/
protected $diskAdapter;

/**
* Is provided disk a local drive.
*
* @var bool
*/
protected $isLocalDisk;

/**
* ChunkStorage constructor.
*
* @param FilesystemContract $disk the desired disk for chunk storage
* @param FilesystemAdapter $disk the desired disk for chunk storage
* @param AbstractConfig $config
*/
public function __construct(FilesystemContract $disk, $config)
public function __construct(FilesystemAdapter $disk, $config)
{
// save the config
$this->config = $config;

// cache the storage path
$this->disk = $disk;

$driver = $this->driver();

// try to get the adapter
if (!method_exists($driver, 'getAdapter')) {
if (!method_exists($this->disk, 'getAdapter')) {
throw new RuntimeException('FileSystem driver must have an adapter implemented');
}

// get the disk adapter
$this->diskAdapter = $driver->getAdapter();
$this->diskAdapter = $this->disk->getAdapter();

// check if its local adapter
$this->isLocalDisk = $this->diskAdapter instanceof Local;
$this->isLocalDisk = $this->diskAdapter instanceof LocalFilesystemAdapter;
}

/**
Expand All @@ -86,7 +61,7 @@ public function __construct(FilesystemContract $disk, $config)
public function getDiskPathPrefix()
{
if ($this->isLocalDisk) {
return $this->diskAdapter->getPathPrefix();
return $this->disk->path('');
}

throw new RuntimeException('The full path is not supported on current disk - local adapter supported only');
Expand Down Expand Up @@ -182,7 +157,7 @@ public function disk()
/**
* Returns the driver.
*
* @return FilesystemInterface
* @return FilesystemOperator
*/
public function driver()
{
Expand Down