Accessing "direct links" via command line

Eventually I’d like to upload (and replace) files via the command line (e.g., with curl) having a valid account and a shared “direct link”.

I can access my files with the complete URL/path [A], and I can access files via explicit shared links (e.g. https://host/s/t8Atkgpjt9qkmWB [B].

A: curl -n -T localfile https://host/remote.php/webdav/path/file.txt
B: curl -u t8Atkgpjt9qkmWB: -T localfile -H 'X-Requested-With: XMLHttpRequest' https://host/public.php/webdav/file.txt

However, I have not found a way to either use the URL of direct links directly (no pun intended) such as https://host/f/53559574 nor convert this to a full path to use method A.

One way would be to allow curl to retrieve the actual location and then apply method A [C]:

C: curl -n -T localfile https://host/remote.php/webdav$(echo $(curl -LIns -o /dev/null -w %{url_effective} https://host/f/53559574) | sed -e 's/.*?dir=//')/

Is there a better way without relying on shell scripting?

(We are currently using NC 17.0.2 or so but I am fine we getting answers for different versions too)

You can mount via WebDAV using an app password.