Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7101ad0

Browse files
committed
[HttpFoundation] Fixed BinaryFileResponse sending wrong Content-Length header for files modified by stream wrappers/filters.
1 parent 6de4359 commit 7101ad0

File tree

1 file changed

+14
-0
lines changed
  • src/Symfony/Component/HttpFoundation/File

1 file changed

+14
-0
lines changed

src/Symfony/Component/HttpFoundation/File/File.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,18 @@ protected function getName($name)
133133

134134
return $originalName;
135135
}
136+
137+
/**
138+
* {@inheritdoc}
139+
*/
140+
public function getSize()
141+
{
142+
// Get the file size from a stream rather than from disk in case it is changed later by
143+
// stream wrappers or stream filters.
144+
$file = fopen($this->getPathname(), 'rb');
145+
$fstat = fstat($file);
146+
fclose($file);
147+
148+
return $fstat['size'];
149+
}
136150
}

0 commit comments

Comments
 (0)