How to turn an "/f/"-link into a URL I can download with curl

Hello,

I just have a basic question:

I have a link of the structure
https://nextcloud.example.com, and I would like to turn it into something that I can download using plain HTTP, e.g. with curl.

Is it possible, and if so, how?

Thanks
Thomas

I have a public share https://cloud.example.com/s/bdhNNhsh there are 3 files in this share

  1. compressed source
  2. md5sum of compressed source
  3. readme.md

you can download/view them by the link in a normal browser or get the full set with curl like

curl https://cloud.example.com/s/bdhNNhsh/download --output NAME.zip

this worked for me with a public share I do not know the significant of domain.tld/s/-link or domain.tld/f/-link

hope this helps let us know how it works for you.

1 Like

The Problem with this is that the “/s/”-link is not password-protected. I can set a password for every file but that is very inconvenient.

I would really like to use the “/f/”-link, if that is possible, which I think it should as that number is the actual “fileId” of the file, accessible by users who are authorized.

I have tried the f link but it seems only valid for internal webbrowser use.

I don’t think you can download the file with this link as for me it opens details of the file or offers me the download option which send the file trough webdav

https://cloud.example.tld/remote.php/webdav/filename.ext

this again works with

curl -u Username:Password https://cloud.example.tld/remote.php/webdav/filename.ext -o filename ext

maybe someone else has downloaded a file by ID and has any idea.

You are looking for nextcloud-raw :

Raw — Nextcloud raw file server

Raw simply returns any requested file, so you can link directly to a file itself (i.e. without any of NextCloud’s interface around it). This enables you to host static web pages, images or other files, for example to link/embed them elsewhere on the web.

For security and privacy, the content is served with a Content-Security-Policy header. This header instructs browsers to not load any remote content, nor execute any scripts that it may contain (of course, the downside is that your web pages cannot use javascript for interactivity).

It works for textfiles and images out of the box and for videos (e.g. to embed in a website) you have to remove two content security headers.

Use at your own risk (I do :wink: )

Hello,
I have a similar usecase : downloading a file from an unique url, the same for all users. (so far I found that only the /f/ link is unique, and I can’t install plugins)

What I am going to do is to use the first 303 response :
When querying a /f/ link with GET or HEAD, you will get a 303 with location /apps/files/?dir=DIR&scrollTo=FILE and you can use DIR and FILE to construct the GET link : /remote.php/dav/files/USER/DIR/FILE

Did anybody find a way to have a unique direct link ?

I am using raw on a daily basis. What are you missing?

I don’t have admin rights on the nextcloud instance.
And even if I convinced admins to install the app, I want to use user rights to download files (I don’t want to use the public share link) : I reference those files in an external database (and thus need an unique link) and want to allow users to download them using their account. Or can nextcloud-raw resolve /f/ links ? I don’t see it in the doc :thinking:

It has never been a problem to me to create an /s/ link for raw but you are right, raw works only on /s/- and not on /f/ links.

What is possible with raw are /u/ links:
When you share a file with another cloud user, he can create his own raw link as follows:

https://yourcloud.tld/apps/raw/u/$username/path/to/file

So if a file named document appears in the filestructure of the user alex I shared with with the path: /SharedWithMe/document, then the link is

https://yourcloud.tld/apps/raw/u/alex/SharedWithMe/document

This /u/ Link is different for every user with access to the file, that is propably not what you are looking for.