Skip to content

Commit 7891aff

Browse files
committed
Fix resolveStream method to handle invalid file paths
1 parent daa56f2 commit 7891aff

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/Storage/AbstractStorage.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,17 @@ public function resolveStream(object|array $obj, ?string $fieldName = null, ?str
117117
{
118118
$path = $this->resolvePath($obj, $fieldName, $className);
119119

120-
if (empty($path)) {
120+
if (empty($path) || !is_file($path)) {
121121
return null;
122122
}
123123

124-
return \fopen($path, 'rb');
124+
$stream = \fopen($path, 'rb');
125+
126+
if (false === $stream) {
127+
return null;
128+
}
129+
130+
return $stream;
125131
}
126132

127133
/**

0 commit comments

Comments
 (0)