$fileName =
$request->request->
getString('fileName'
);
$destination =
preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',
$fileName);
if ($destination === ''
) { throw MediaException::
emptyMediaFilename();
} if (!\
is_string($destination)) { throw MediaException::
illegalFileName($fileName, 'Filename must be a string'
);
} $this->fileSaver->
renameMedia($mediaId,
$destination,
$context);
return $responseFactory->
createRedirectResponse($this->mediaDefinition,
$mediaId,
$request,
$context);
} #[Route(path: '/api/_action/media/provide-name', name: 'api.action.media.provide-name', methods: ['GET'])]
public function provideName(Request
$request, Context
$context): JsonResponse
{ $fileName =
$request->query->
getString('fileName'
);
$preferredFileName =
preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',
$fileName);
if (!\
is_string($preferredFileName)) {