Skip to content

Commit

Permalink
Add drop zone support for parallelChunkUploads
Browse files Browse the repository at this point in the history
  • Loading branch information
pionl committed May 8, 2018
1 parent 3521fdc commit 202eb34
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ Setup is composed in 3 steps:

| Library | Wiki | single & chunk upload | simultaneous uploads |
|---- |----|----|----|
| [resumable.js](https://github.com/23/resumable.js) | [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki/jquery-file-upload) | :heavy_check_mark: | :heavy_check_mark: |
| [DropZone](https://gitlab.com/meno/dropzone/) | [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki/dropzone) | :heavy_check_mark: | :heavy_check_mark: |
| [jQuery-File-Upload](https://github.com/blueimp/jQuery-File-Upload) | [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki/blueimp-file-upload) | :heavy_check_mark: | :heavy_multiplication_x: |
| [Plupload](https://github.com/moxiecode/plupload) | [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki/plupload) | :heavy_check_mark: | :heavy_multiplication_x: |
| [resumable.js](https://github.com/23/resumable.js) | [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki/jquery-file-upload) | :heavy_check_mark: | :heavy_check_mark: |
| [DropZone](https://gitlab.com/meno/dropzone/) | [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki/dropzone) | :heavy_check_mark: | :heavy_multiplication_x: |

For more detailed information (tips) use the [Wiki](https://github.com/pionl/laravel-chunk-upload/wiki) or for working example continue to separate repository with [example](https://github.com/pionl/laravel-chunk-upload-example).

Expand Down
4 changes: 2 additions & 2 deletions src/Handler/AbstractHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public static function canUseSession()
* provide custom additional name at the end of the generated file name. All chunk
* files has .part extension
*
* @param string|null $additionalName
* @param string|null $currentChunkIndex
* @param string|null $additionalName Make the name more unique (example: use id from request)
* @param string|null $currentChunkIndex Add the chunk index for parallel upload
*
* @return string
*
Expand Down
29 changes: 28 additions & 1 deletion src/Handler/DropZoneUploadHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
use Illuminate\Http\Request;
use Illuminate\Http\UploadedFile;
use Pion\Laravel\ChunkUpload\Config\AbstractConfig;
use Pion\Laravel\ChunkUpload\Exceptions\ChunkSaveException;
use Pion\Laravel\ChunkUpload\Save\ParallelSave;
use Pion\Laravel\ChunkUpload\Storage\ChunkStorage;

class DropZoneUploadHandler extends ChunksInRequestUploadHandler
{
Expand Down Expand Up @@ -34,9 +37,33 @@ public function __construct(Request $request, $file, $config)
$this->fileUuid = $request->get(self::CHUNK_UUID_INDEX);
}

/**
* Returns the chunk save instance for saving
*
* @param ChunkStorage $chunkStorage the chunk storage
*
* @return ParallelSave
* @throws ChunkSaveException
* @throws ChunkSaveException
*/
public function startSaving($chunkStorage)
{
return new ParallelSave(
$this->getTotalChunksFromRequest($this->request),
$this->file,
$this,
$chunkStorage,
$this->config
);
}

/**
* Builds the chunk file name from file uuid and current chunk
* @return string
*/
public function getChunkFileName()
{
return $this->createChunkFileName($this->fileUuid);
return $this->createChunkFileName($this->fileUuid, $this->getCurrentChunk());
}

/**
Expand Down

0 comments on commit 202eb34

Please sign in to comment.