CodeExplorer openDestinationStream example
private readonly bool
$enableUrlValidation = true,
private readonly int
$maxFileSize = 0
) { } public function fetchRequestData(Request
$request, string
$fileName): MediaFile
{ $extension =
$this->
getExtensionFromRequest($request);
$expectedLength =
(int) $request->headers->
get('content-length'
);
$inputStream =
$request->
getContent(true
);
$destStream =
$this->
openDestinationStream($fileName);
try { $bytesWritten =
$this->
copyStreams($inputStream,
$destStream, 0
);
} finally { fclose($inputStream);
fclose($destStream);
} if ($expectedLength !==
$bytesWritten) { throw MediaException::
invalidContentLength();
}