Skip to content

Commit 8d8cd3b

Browse files
authored
Add Flow.js driver (#46)
* Add Flow.js driver * Remove imports * Update README.md * Update supported list of drivers in config * Change namespace
1 parent e09b390 commit 8d8cd3b

File tree

5 files changed

+362
-1
lines changed

5 files changed

+362
-1
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ project at the moment is [tus](https://tus.io/).
3636
- [Monolith](#monolith-driver)
3737
- [Blueimp](#blueimp-driver)
3838
- [DropzoneJS](#dropzonejs-driver)
39+
- [Flow.js](#flow-js-driver)
3940
- [Resumable.js](#resumable-js-driver)
4041
- [Identifiers](#identifiers)
4142
- [Session identifier](#session-identifier)
@@ -148,6 +149,7 @@ Service | Driver name | Chunk upload | Resumable
148149
[Monolith](#monolith-driver) | `monolith` | no | no
149150
[Blueimp](#blueimp-driver) | `blueimp` | yes | yes
150151
[DropzoneJS](#dropzonejs-driver) | `dropzone` | yes | no
152+
[Flow.js](#flow-js-driver) | `flow-js` | yes | yes
151153
[Resumable.js](#resumable-js-driver) | `resumable-js` | yes | yes
152154

153155
### Monolith driver
@@ -166,6 +168,12 @@ This driver handles requests made by the Blueimp jQuery File Upload client libra
166168

167169
This driver handles requests made by the DropzoneJS client library.
168170

171+
### Flow.js driver
172+
173+
[website](https://github.com/flowjs/flow.js)
174+
175+
This driver handles requests made by the Flow.js client library.
176+
169177
### Resumable.js driver
170178

171179
[website](http://resumablejs.com/)

config/chunk-uploader.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
| throughout your application here. By default, the module is setup for
1313
| monolith upload.
1414
|
15-
| Supported: "monolith", "blueimp", "dropzone", "resumable-js"
15+
| Supported: "monolith", "blueimp", "dropzone", "flow-js", "resumable-js"
1616
|
1717
*/
1818

@@ -118,6 +118,27 @@
118118

119119
],
120120

121+
/*
122+
|--------------------------------------------------------------------------
123+
| Flow.js Options
124+
|--------------------------------------------------------------------------
125+
|
126+
| Here you may configure the options for the Flow.js driver.
127+
|
128+
*/
129+
130+
'flow-js' => [
131+
132+
// The name of the multipart request parameter to use for the file chunk
133+
'param' => 'file',
134+
135+
// HTTP method for chunk test request.
136+
'test-method' => Illuminate\Http\Request::METHOD_GET,
137+
// HTTP method to use when sending chunks to the server (POST, PUT, PATCH).
138+
'upload-method' => Illuminate\Http\Request::METHOD_POST,
139+
140+
],
141+
121142
/*
122143
|--------------------------------------------------------------------------
123144
| Resumable.js Options

src/Driver/FlowJsUploadDriver.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace CodingSocks\ChunkUploader\Driver;
4+
5+
class FlowJsUploadDriver extends ResumableJsUploadDriver
6+
{
7+
/**
8+
* ResumableJsUploadDriver constructor.
9+
*
10+
* @param array $config
11+
*/
12+
public function __construct($config)
13+
{
14+
$config['parameter-namespace'] = '';
15+
$config['parameter-names'] = [
16+
// The name of the chunk index (base-1) in the current upload POST parameter to use for the file chunk.
17+
'chunk-number' => 'flowChunkNumber',
18+
// The name of the total number of chunks POST parameter to use for the file chunk.
19+
'total-chunks' => 'flowTotalChunks',
20+
// The name of the general chunk size POST parameter to use for the file chunk.
21+
'chunk-size' => 'flowChunkSize',
22+
// The name of the total file size number POST parameter to use for the file chunk.
23+
'total-size' => 'flowTotalSize',
24+
// The name of the unique identifier POST parameter to use for the file chunk.
25+
'identifier' => 'flowIdentifier',
26+
// The name of the original file name POST parameter to use for the file chunk.
27+
'file-name' => 'flowFilename',
28+
// The name of the file's relative path POST parameter to use for the file chunk.
29+
'relative-path' => 'flowRelativePath',
30+
// The name of the current chunk size POST parameter to use for the file chunk.
31+
'current-chunk-size' => 'flowCurrentChunkSize',
32+
];
33+
parent::__construct($config);
34+
}
35+
}

src/UploadManager.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Support\Manager;
66
use CodingSocks\ChunkUploader\Driver\BlueimpUploadDriver;
77
use CodingSocks\ChunkUploader\Driver\DropzoneUploadDriver;
8+
use CodingSocks\ChunkUploader\Driver\FlowJsUploadDriver;
89
use CodingSocks\ChunkUploader\Driver\MonolithUploadDriver;
910
use CodingSocks\ChunkUploader\Driver\ResumableJsUploadDriver;
1011

@@ -28,6 +29,11 @@ public function createDropzoneDriver()
2829
return new DropzoneUploadDriver($this->app['config']['chunk-uploader.dropzone']);
2930
}
3031

32+
public function createFlowJsDriver()
33+
{
34+
return new FlowJsUploadDriver($this->app['config']['chunk-uploader.resumable-js']);
35+
}
36+
3137
public function createResumableJsDriver()
3238
{
3339
return new ResumableJsUploadDriver($this->app['config']['chunk-uploader.resumable-js']);

0 commit comments

Comments
 (0)