Skip to content

Commit

Permalink
Merge pull request #166 from hhovakimyan/feature/add-method-returning…
Browse files Browse the repository at this point in the history
…-file-path-in-UploadedFile-class

Add method returning client provided file path
  • Loading branch information
l0gicgate committed Aug 18, 2020
2 parents 5b19133 + 346854b commit 832912c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@ public function getSize(): ?int
{
return $this->size;
}

/**
* Returns the client-provided full path to the file
*
* @internal This method is not part of the PSR-7 standard
*
* @return string
*/
public function getFilePath(): string
{
return $this->file;
}

/**
* Create a normalized tree of UploadedFile instances from the Environment.
Expand Down
3 changes: 3 additions & 0 deletions tests/UploadedFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public function testConstructor()
$this->assertEquals($attr['type'], $uploadedFile->getClientMediaType());
$this->assertEquals($attr['size'], $uploadedFile->getSize());
$this->assertEquals($attr['error'], $uploadedFile->getError());
$this->assertEquals($attr['tmp_name'], $uploadedFile->getFilePath());

return $uploadedFile;
}
Expand Down Expand Up @@ -183,6 +184,7 @@ public function testConstructorSapi()
$this->assertEquals($attr['type'], $uploadedFile->getClientMediaType());
$this->assertEquals($attr['size'], $uploadedFile->getSize());
$this->assertEquals($attr['error'], $uploadedFile->getError());
$this->assertEquals($attr['tmp_name'], $uploadedFile->getFilePath());

return $uploadedFile;
}
Expand Down Expand Up @@ -409,6 +411,7 @@ private function runFileUploadWithTempStreamTest(callable $streamFactory, callab
$this->assertSame($error, $file->getError());
$this->assertSame($clientFilename, $file->getClientFilename());
$this->assertSame($clientMediaType, $file->getClientMediaType());
$this->assertSame($stream->getMetadata('uri'), $file->getFilePath());
}

/**
Expand Down

0 comments on commit 832912c

Please sign in to comment.