diff --git a/src/ChunkFile.php b/src/ChunkFile.php index 072215f..bea4515 100644 --- a/src/ChunkFile.php +++ b/src/ChunkFile.php @@ -94,11 +94,10 @@ public function appendFile($source, int $index = 0): ChunkFile /** * @throws FileNotFoundException */ - public function createUploadedFile($chunks = null, $storageFile = null): UploadedFile + public function createUploadedFile($chunks = null): UploadedFile { $chunkFile = $this->chunkFile(); - - $storageFile = $storageFile ?: $this->storageFile(); + $storageFile = $this->storageFile(); if (is_null($chunks) === false) { for ($i = 0; $i < $chunks; $i++) { diff --git a/src/FileAPI.php b/src/FileAPI.php index ae9d6e2..da32501 100644 --- a/src/FileAPI.php +++ b/src/FileAPI.php @@ -51,7 +51,7 @@ protected function receiveChunked(string $name): UploadedFile $mimeType = $this->request->header('content-type'); $uuid = $this->request->get('token'); - $chunkFile = $this->createChunkFile($originalName, $mimeType, $uuid); + $chunkFile = $this->createChunkFile($originalName, $uuid, $mimeType); $chunkFile->appendStream($this->request->getContent(true), $start); if (! $this->isCompleted($name)) { diff --git a/src/Filesystem.php b/src/Filesystem.php index 95fdb7e..d663273 100644 --- a/src/Filesystem.php +++ b/src/Filesystem.php @@ -17,7 +17,11 @@ public function basename($path): string public function tmpfilename(string $path, string $hash = null): string { - return md5($path.$hash).'.'.strtolower($this->extension($path)); + if (empty($hash)) { + $hash = md5($path); + } + + return $hash.'.'.strtolower($this->extension($path)); } /** diff --git a/tests/FilesystemTest.php b/tests/FilesystemTest.php index 25efa72..6e1a923 100644 --- a/tests/FilesystemTest.php +++ b/tests/FilesystemTest.php @@ -27,7 +27,7 @@ public function testTmpfilename(): void $path = __FILE__; $hash = uniqid('', true); - $this->assertSame(md5($path.$hash).'.php', $files->tmpfilename($path, $hash)); + $this->assertSame($hash.'.php', $files->tmpfilename($path, $hash)); } /**