CodeExplorer copyStreams example
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();
} return new MediaFile( $fileName,