Skip to content

Commit 4a14bc7

Browse files
authored
Add simple-uploader.js driver (#48)
* Add simple-uploader.js driver * Update README.md * Change namespace
1 parent 8d8cd3b commit 4a14bc7

File tree

5 files changed

+365
-8
lines changed

5 files changed

+365
-8
lines changed

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ project at the moment is [tus](https://tus.io/).
3838
- [DropzoneJS](#dropzonejs-driver)
3939
- [Flow.js](#flow-js-driver)
4040
- [Resumable.js](#resumable-js-driver)
41+
- [simple-uploader.js](#simple-uploader-js-driver)
4142
- [Identifiers](#identifiers)
4243
- [Session identifier](#session-identifier)
4344
- [Contribution](#contribution)
@@ -144,13 +145,14 @@ If you wrote a custom driver that others might find useful, please consider addi
144145

145146
Below is a list of available drivers along with their individual specs:
146147

147-
Service | Driver name | Chunk upload | Resumable
148-
-------------------------------------|----------------|--------------|-----------
149-
[Monolith](#monolith-driver) | `monolith` | no | no
150-
[Blueimp](#blueimp-driver) | `blueimp` | yes | yes
151-
[DropzoneJS](#dropzonejs-driver) | `dropzone` | yes | no
152-
[Flow.js](#flow-js-driver) | `flow-js` | yes | yes
153-
[Resumable.js](#resumable-js-driver) | `resumable-js` | yes | yes
148+
Service | Driver name | Chunk upload | Resumable
149+
-------------------------------------------------|----------------------|--------------|-----------
150+
[Monolith](#monolith-driver) | `monolith` | no | no
151+
[Blueimp](#blueimp-driver) | `blueimp` | yes | yes
152+
[DropzoneJS](#dropzonejs-driver) | `dropzone` | yes | no
153+
[Flow.js](#flow-js-driver) | `flow-js` | yes | yes
154+
[Resumable.js](#resumable-js-driver) | `resumable-js` | yes | yes
155+
[simple-uploader.js](#simple-uploader-js-driver) | `simple-uploader-js` | yes | yes
154156

155157
### Monolith driver
156158

@@ -180,6 +182,12 @@ This driver handles requests made by the Flow.js client library.
180182

181183
This driver handles requests made by the Resumable.js client library.
182184

185+
### simple-uploader.js driver
186+
187+
[website](https://github.com/simple-uploader/Uploader)
188+
189+
This driver handles requests made by the simple-uploader.js client library.
190+
183191
## Identifiers
184192

185193
In some cases an identifier is needed for the uploaded file when the client side library does not provide one.

config/chunk-uploader.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
| throughout your application here. By default, the module is setup for
1313
| monolith upload.
1414
|
15-
| Supported: "monolith", "blueimp", "dropzone", "flow-js", "resumable-js"
15+
| Supported: "monolith", "blueimp", "dropzone", "flow-js", "resumable-js",
16+
| "simple-uploader-js"
1617
|
1718
*/
1819

@@ -184,4 +185,25 @@
184185

185186
],
186187

188+
/*
189+
|--------------------------------------------------------------------------
190+
| simple-uploader.js Options
191+
|--------------------------------------------------------------------------
192+
|
193+
| Here you may configure the options for the simple-uploader.js driver.
194+
|
195+
*/
196+
197+
'simple-uploader-js' => [
198+
199+
// The name of the multipart request parameter to use for the file chunk
200+
'param' => 'file',
201+
202+
// HTTP method for chunk test request.
203+
'test-method' => Illuminate\Http\Request::METHOD_GET,
204+
// HTTP method to use when sending chunks to the server (POST, PUT, PATCH).
205+
'upload-method' => Illuminate\Http\Request::METHOD_POST,
206+
207+
],
208+
187209
];
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace CodingSocks\ChunkUploader\Driver;
4+
5+
class SimpleUploaderJsUploadDriver extends ResumableJsUploadDriver
6+
{
7+
public function __construct($config)
8+
{
9+
$config['parameter-namespace'] = '';
10+
$config['parameter-names'] = [
11+
// The name of the chunk index (base-1) in the current upload POST parameter to use for the file chunk.
12+
'chunk-number' => 'chunkNumber',
13+
// The name of the total number of chunks POST parameter to use for the file chunk.
14+
'total-chunks' => 'totalChunks',
15+
// The name of the general chunk size POST parameter to use for the file chunk.
16+
'chunk-size' => 'chunkSize',
17+
// The name of the total file size number POST parameter to use for the file chunk.
18+
'total-size' => 'totalSize',
19+
// The name of the unique identifier POST parameter to use for the file chunk.
20+
'identifier' => 'identifier',
21+
// The name of the original file name POST parameter to use for the file chunk.
22+
'file-name' => 'filename',
23+
// The name of the file's relative path POST parameter to use for the file chunk.
24+
'relative-path' => 'relativePath',
25+
// The name of the current chunk size POST parameter to use for the file chunk.
26+
'current-chunk-size' => 'currentChunkSize',
27+
];
28+
parent::__construct($config);
29+
}
30+
}

src/UploadManager.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use CodingSocks\ChunkUploader\Driver\FlowJsUploadDriver;
99
use CodingSocks\ChunkUploader\Driver\MonolithUploadDriver;
1010
use CodingSocks\ChunkUploader\Driver\ResumableJsUploadDriver;
11+
use CodingSocks\ChunkUploader\Driver\SimpleUploaderJsUploadDriver;
1112

1213
class UploadManager extends Manager
1314
{
@@ -39,6 +40,11 @@ public function createResumableJsDriver()
3940
return new ResumableJsUploadDriver($this->app['config']['chunk-uploader.resumable-js']);
4041
}
4142

43+
public function createSimpleUploaderJsDriver()
44+
{
45+
return new SimpleUploaderJsUploadDriver($this->app['config']['chunk-uploader.simple-uploader-js']);
46+
}
47+
4248
/**
4349
* Get the default driver name.
4450
*

0 commit comments

Comments
 (0)