Skip to content

Commit

Permalink
createStreamFromFile on files without upload error (#43)
Browse files Browse the repository at this point in the history
* createStreamFromFile on files without upload error

* Update ServerRequestCreator.php

* Update ServerRequestCreator.php

* code formatting

* Check if upload is okey

Co-authored-by: Nyholm <tobias.nyholm@gmail.com>
  • Loading branch information
frkinta and Nyholm authored May 10, 2021
1 parent 7542bd7 commit 33aa7c9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/ServerRequestCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,14 @@ private function createUploadedFileFromSpec(array $value)
return $this->normalizeNestedFileSpec($value);
}

try {
$stream = $this->streamFactory->createStreamFromFile($value['tmp_name']);
} catch (\RuntimeException $e) {
if (UPLOAD_ERR_OK !== $value['error']) {
$stream = $this->streamFactory->createStream();
} else {
try {
$stream = $this->streamFactory->createStreamFromFile($value['tmp_name']);
} catch (\RuntimeException $e) {
$stream = $this->streamFactory->createStream();
}
}

return $this->uploadedFileFactory->createUploadedFile(
Expand Down

0 comments on commit 33aa7c9

Please sign in to comment.