try { $uploadedFile =
$this->mediaService->
fetchFile($request,
$tempFile);
$this->fileSaver->
persistFileToMedia( $uploadedFile,
$destination,
$mediaId,
$context );
$this->eventDispatcher->
dispatch(new MediaUploadedEvent($mediaId,
$context));
} finally { unlink($tempFile);
} return $responseFactory->
createRedirectResponse($this->mediaDefinition,
$mediaId,
$request,
$context);
} #[Route(path: '/api/_action/media/{mediaId}/rename', name: 'api.action.media.rename', methods: ['POST'])]
public function renameMediaFile(Request
$request, string
$mediaId, Context
$context, ResponseFactoryInterface
$responseFactory): Response
{ $fileName =
$request->request->
getString('fileName'
);