Skip to content

Commit

Permalink
fix file api bug
Browse files Browse the repository at this point in the history
  • Loading branch information
recca0120 committed May 1, 2023
1 parent 2e54413 commit 514294a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/ChunkFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
2 changes: 1 addition & 1 deletion src/FileAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
6 changes: 5 additions & 1 deletion src/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down

0 comments on commit 514294a

Please sign in to comment.