public function __construct( private readonly FileUrlValidatorInterface
$fileUrlValidator,
private readonly bool
$enableUrlUploadFeature = true,
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);
}