From 12c3ec61c9278b700ed3a036b7d6f069958b944b Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sun, 17 Dec 2023 00:42:05 +0100 Subject: [PATCH 1/3] fix isUploadComplete and typos --- src/Resumable.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Resumable.php b/src/Resumable.php index a487237..ba43580 100644 --- a/src/Resumable.php +++ b/src/Resumable.php @@ -70,7 +70,7 @@ public function setResumableOption(array $resumableOption) $this->resumableOption = array_merge($this->resumableOption, $resumableOption); } - // sets original filename and extenstion, blah blah + // sets original filename and extension, blah blah public function preProcess() { if (!empty($this->resumableParams())) { @@ -243,7 +243,7 @@ private function createFileAndDeleteTmp($identifier, $filename) if ($this->createFileFromChunks($chunkFiles, $this->filepath) && $this->deleteTmpFolder) { $tmpFolder->delete(); - $this->uploadComplete = true; + $this->isUploadComplete = true; } } @@ -295,14 +295,14 @@ public function tmpChunkDir($identifier) /** * make directory if it doesn't exists (Immune against the race condition) - * - * - * since the resuamble is usually used with simultaneously uploads, - * this sometimes resulted in directory creation btween the *is_dir* check + * + * + * since the resumable is usually used with simultaneously uploads, + * this sometimes resulted in directory creation between the *is_dir* check * and *mkdir* then following race condition. * in this setup it will shut down the mkdir error * then try to check if directory is created after that - * + * * @param string $path the directoryPath to ensure * @return void * @throws \Exception @@ -361,7 +361,7 @@ public function createFileFromChunks($chunkFiles, $destFile) public function moveUploadedFile($file, $destFile) { - //workaround cakephp error regarding: TMP not defined + //workaround cakephp error regarding: TMP not defined define("TMP",sys_get_temp_dir()); $file = new File($file); From 73a176b852ff59c8e252424ca40608e1e70ee016 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sun, 17 Dec 2023 00:42:14 +0100 Subject: [PATCH 2/3] Fix the README --- readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index ce08d66..6573be3 100644 --- a/readme.md +++ b/readme.md @@ -10,7 +10,7 @@ To install, use composer: ## How to use **upload.php** -``` +```php getOriginalFilename(Resumable::WITHOUT_EXTENSION); // will gove you "original Name" instead of "original Name.png" @@ -62,6 +62,6 @@ if (true === $resumable->isUploadComplete()) { // true when the final file has b ``` ## Testing -``` +```sh $ ./vendor/bin/phpunit ``` From 658e8543943d56ad4204eaaee9f83efdf8b57fcc Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sun, 3 Dec 2023 15:43:50 +0100 Subject: [PATCH 3/3] Force cast some parameters --- src/Resumable.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Resumable.php b/src/Resumable.php index ba43580..294a447 100644 --- a/src/Resumable.php +++ b/src/Resumable.php @@ -177,9 +177,9 @@ public function handleTestChunk() { $identifier = $this->resumableParam($this->resumableOption['identifier']); $filename = $this->resumableParam($this->resumableOption['filename']); - $chunkNumber = $this->resumableParam($this->resumableOption['chunkNumber']); - $chunkSize = $this->resumableParam($this->resumableOption['chunkSize']); - $totalChunks = $this->resumableParam($this->resumableOption['totalChunks']); + $chunkNumber = (int) $this->resumableParam($this->resumableOption['chunkNumber']); + $chunkSize = (int) $this->resumableParam($this->resumableOption['chunkSize']); + $totalChunks = (int) $this->resumableParam($this->resumableOption['totalChunks']); if (!$this->isChunkUploaded($identifier, $filename, $chunkNumber)) { return $this->response->header(204); @@ -199,9 +199,9 @@ public function handleChunk() $file = $this->request->file(); $identifier = $this->resumableParam($this->resumableOption['identifier']); $filename = $this->resumableParam($this->resumableOption['filename']); - $chunkNumber = $this->resumableParam($this->resumableOption['chunkNumber']); - $chunkSize = $this->resumableParam($this->resumableOption['chunkSize']); - $totalChunks = $this->resumableParam($this->resumableOption['totalChunks']); + $chunkNumber = (int) $this->resumableParam($this->resumableOption['chunkNumber']); + $chunkSize = (int) $this->resumableParam($this->resumableOption['chunkSize']); + $totalChunks = (int) $this->resumableParam($this->resumableOption['totalChunks']); if (!$this->isChunkUploaded($identifier, $filename, $chunkNumber)) { $chunkFile = $this->tmpChunkDir($identifier) . DIRECTORY_SEPARATOR . $this->tmpChunkFilename($filename, $chunkNumber);