Dynamic adjustment of the HTTP response header based on URI parts

How do you do?

I use Backblaze as my object storage.
As described in some instructions, I have built a “CDN” with Cloudflare via a CNAME. I still customize the HTTP response headers a little, which all works wonderfully.

Now I have a current question, a URL looks something like this:


This also displays the file perfectly.
Then I took a second URL:


and set the HTTP header, which leads to the download.

Wonderful. However, the file name is then dsflksdfjsdf.pdf. Now I thought, ok, I’ll adjust the URL as follows:


The “test.pdf” should become the new file name in the download, which I would then create as follows:

Now my question, is it possible that I pass the “new” file name dynamically and write it accordingly in the header?
Important, of course, the part “test.pdf/” must be removed from the URl so that Blackblaze returns the correct file