Making a file accessible via URL that's added in a Link field

My client needs to be able to a update a daily Menu for their restaurant. For simplicities sake they upload it via the panel to the site route and then it’s linked to on a a page via a Link field entry:

When clicking this link it opens the version in the media folder, however the file on the site route is not accessible (only via the content folder). They need this for clean urls such as restaurantname.de/speisekarte.pdf . What would be the best way to approach this? Linking to the file in the media folder is fine, but the actual file on the server would be better.

Hey,

i think i would try a route for this usecase.
Something like

[
			'pattern' => 'speisekarte.pdf',
			'action' => function() {
				$speisekarte = site()->speisekarte()->tofile();

				go($speisekarte->url());
			}
		]

it will “redirect” to the file in the media folder but the url is clean.

Yeah, this is what I ended up doing. Not ideal but it works. Thanks!

Maybe this one is a better solution. it keeps the url and does not redirect

[
			'pattern' => 'speisekarte.pdf',
			'action' => function() {
				$speisekarte = site()->speisekarte()->tofile();

				if (!$speisekarte) {
					return ['error' => 'File not found'];
				}
				
				return response::file($speisekarte->root());
			}
		]