File tree Expand file tree Collapse file tree 4 files changed +58
-1
lines changed Expand file tree Collapse file tree 4 files changed +58
-1
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ project at the moment is [tus](https://tus.io/).
4141 - [ simple-uploader.js] ( #simple-uploader-js-driver )
4242- [ Identifiers] ( #identifiers )
4343 - [ Session identifier] ( #session-identifier )
44+ - [ NOP identifier] ( #nop-identifier )
4445- [ Contribution] ( #contribution )
4546- [ License] ( #license )
4647
@@ -197,10 +198,16 @@ file for a specific client. Without the identifier collisions can happen.
197198Service | Driver name
198199------------------------------------------|-------------
199200[ Session identifier] ( #session-identifier ) | ` session `
201+ [ NOP identifier] ( #nop-identifier ) | ` nop `
200202
201203### Session identifier
202204
203- This identifier uses the client session and the original file name to create an identifier for the upload file.
205+ This identifier uses the client session and, the original file name to create an identifier for the upload file.
206+
207+ ### NOP identifier
208+
209+ This identifier uses the original file name to create an identifier for the upload file. This does not abstract the file
210+ identifier which can be useful for testing.
204211
205212## Contribution
206213
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace CodingSocks \ChunkUploader \Identifier ;
4+
5+ class NopIdentifier extends Identifier
6+ {
7+ public function generateIdentifier (string $ data ): string
8+ {
9+ return $ data ;
10+ }
11+ }
Original file line number Diff line number Diff line change 22
33namespace CodingSocks \ChunkUploader ;
44
5+ use CodingSocks \ChunkUploader \Identifier \NopIdentifier ;
56use CodingSocks \ChunkUploader \Identifier \SessionIdentifier ;
67use Illuminate \Support \Manager ;
78
@@ -12,6 +13,11 @@ public function createSessionDriver()
1213 return new SessionIdentifier ();
1314 }
1415
16+ public function createNopDriver ()
17+ {
18+ return new NopIdentifier ();
19+ }
20+
1521 /**
1622 * Get the default driver name.
1723 *
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace CodingSocks \ChunkUploader \Tests \Identifier ;
4+
5+ use CodingSocks \ChunkUploader \Identifier \NopIdentifier ;
6+ use PHPUnit \Framework \TestCase ;
7+
8+ class NopIdentifierTest extends TestCase
9+ {
10+ /**
11+ * @var \CodingSocks\ChunkUploader\Identifier\SessionIdentifier
12+ */
13+ private $ identifier ;
14+
15+ protected function setUp (): void
16+ {
17+ parent ::setUp ();
18+
19+ $ this ->identifier = new NopIdentifier ();
20+ }
21+
22+ public function testGenerateIdentifier ()
23+ {
24+ $ identifier = $ this ->identifier ->generateIdentifier ('any_string ' );
25+ $ this ->assertEquals ('any_string ' , $ identifier );
26+ }
27+
28+ public function testUploadedFileIdentifierName ()
29+ {
30+ $ identifier = $ this ->identifier ->generateFileIdentifier (200 , 'any_filename.ext ' );
31+ $ this ->assertEquals ('200_any_filename.ext ' , $ identifier );
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments