Get file from nextCloud and view it on a public site with a fileViewer

Hello, could you help me please…
I got a wordPress site and I need to view some file which are stored in nextCloud.
I already manage to create a direct link to the file but… when I try to view… it needs a credential.

So, before putting the direct link in the tag. I made a fetch function but unfortunately I always got a 401 error code…:exploding_head:

However… I made the test from postman with the same basic auth credential… I directly get the file. :expressionless:

why I get the 401 on my site… if you could help please. :pray:

Use public share and add /download e.g. https://cloud.server.tld/s/abcdefghijklmno/download

thanks… that’s could be great if I only have a minimal number of file…
but here In a folder there could be a lot of subfolder :sweat_smile:.

I used DAV file to create the direct link to each file
like this:

https://{{ address }}/remote.php/dav/files/{{ file owner name }}/{{ path to file }}/{{ file }}… it’s automatically generated by a third server…

in another desktop app I use fetch() with basic auth and it work …
but on the site always get the 401… I’m stuck😭

I think this is not possible because it is WebDAV and you need the authentication of a user.

But you can share all files in one share and configure the share link. It would then look like this:

Example shared folder
https://cloud.server.tld/index.php/s/EskdRyytYAMHdxG

photo Frog.jpg in top folder:
https://cloud.server.tld/index.php/s/EskdRyytYAMHdxG/download?path=&files=Frog.jpg

PDF “Nextcloud Manual.pdf” in top folder
https://cloud.server.tld/index.php/s/EskdRyytYAMHdxG/download?path=&files=Nextcloud%20Manual.pdf

PDF “Nextcloud flyer.pdf” in subfolder “Documents”:
https://cloud.server.tld/index.php/s/EskdRyytYAMHdxG/download?path=%2FDocuments&files=Nextcloud%20flyer.pdf

thanks a lot… that was the best way… :grin::beers:

1 Like