Server: Embed public files on a Website

Created on 20 Sep 2016  路  20Comments  路  Source: nextcloud/server

Is there a way to embed a public folder by iframe or php into a Website,
so that a user can browse a folder and download the files he or she needs.
Or do you know a nice Webdav browsing class for PHP?
We want to share some public data which will be perhaps managed in a nextcloud.

0. Needs triage enhancement files sharing help wanted

Most helpful comment

There's more than iframing this.

What about embedding an image on a public website, in a forum somewhere?

Say you're on a forum like here:
https://forum.kde.org/viewtopic.php?f=221&t=137440&p=367768#p367768
and you want to embed an image from a Nextcloud instance, you get a URL like:
https://share.kde.org/index.php/apps/files_sharing/ajax/publicpreview.php?x=600&y=558&a=true&file=sharing.png&t=tH1ZvenNd3JPFM8&scalingup=0

A few more points:

@nextcloud/designers do you think it would make sense to try and simplify these links and make it easier to embed images from a Nextcloud instance in other places? I'd actually love to put a screenshot on my NC and directly paste the image here...

All 20 comments

Is there a way to embed a public folder by iframe or php into a Website

This imposes a security risk, if not from same origin and is not advised. 馃榿
@nextcloud/security Right? Do you know something? -->

Or do you know a nice Webdav browsing class for PHP?

There's more than iframing this.

What about embedding an image on a public website, in a forum somewhere?

Say you're on a forum like here:
https://forum.kde.org/viewtopic.php?f=221&t=137440&p=367768#p367768
and you want to embed an image from a Nextcloud instance, you get a URL like:
https://share.kde.org/index.php/apps/files_sharing/ajax/publicpreview.php?x=600&y=558&a=true&file=sharing.png&t=tH1ZvenNd3JPFM8&scalingup=0

A few more points:

@nextcloud/designers do you think it would make sense to try and simplify these links and make it easier to embed images from a Nextcloud instance in other places? I'd actually love to put a screenshot on my NC and directly paste the image here...

@jospoortvliet I opened a dedicated issue, because the use case @skerbis mentioned, is a little bit different and I like your idea!

@skerbis Why does your "folder" have to be embedded into another site? Would theming and a direct link not be enough?

See also https://github.com/nextcloud/server/issues/2523#issuecomment-265085663 for the security aspects ;)

@eppfel the best thing would be a PHP-Class which allwos me to show the Folders, Files and Subfolders inside the Website. The Folder is managed inside nextcloud but should be shown on the Website. Perhaps does anyone know a PHP-Script for integrating a webdav-browser?

or short is there a api for that?

Well there's webDAV & the OCS API, but you'd have to write your own view. Perhaps CMS Pico can help?

https://github.com/nextcloud/cms_pico

Any progress on this matter? It would be excellent feature to view Nextcloud public link "folder" straight from Wordpress.

@Xemanth or any other "real" CMS ;-)

Thanks, NC team & fans! Direct share link for an Image works great in v13!
It would be great if this can grow up to be done for a folder or a video for purpose of HTML image/video storage backend.
I'm running NC on VPS and I host a static HTML page on the same VPS behind Nginx on the same domain/cloud is NC served by Nginx.
I was looking into OCS APIs and user created just for accessing shared folders for accessing user shares and serving folder-images for this static HTML page or thinking of using just bare share URL generated from NC, but still can't figure it out what would be the best way to accomplish this if possible without adding any security flaws.
I don't want to go iframe so is there a way to use raw shared folder content?
Is there a way to access/list public shared folder using OCS API without user authentication?

Kind Regards,

@mveplus it must be possible, though I don't know how... As I said, you can use cms_pico for some things, at least - https://nextcloud.com/blog/nextcloud-introduces-easy-website-builder-for-education-edition-with-picocms/

@mveplus
There are few ways to do it. Here is how I do it:

Thanks, @jospoortvliet and @SlavikCA I have now a few more thoughts to chew up and tinker.
I've looked at picocms it looks interesting, for time being I think vhost option would serve me better, I'm going to try it ;)

Thanks for taking the time to replay! I'm sure if there is enough interest NC team will come up with a solution.
Cheers

@SlavikCA
I like your approach. I'm fairly new to vhost setups. Can you share an example of how this is setup. I am wanting to do this with Ghost and Nextcloud.

Works for me:
https://www.ortlepp.eu/blog/2016/access_nextcloud_with_php_and_curl.html

The link is not working. It would be nice with a description on how to do this :)

@srednax it's documented here at the end: https://docs.nextcloud.com/server/13.0.0/user_manual/files/access_webdav.html#accessing-files-using-curl

https://docs.nextcloud.com/server/latest/user_manual/files/access_webdav.html#accessing-files-using-curl

(above link will always point to the latest documentation)

Here's a PHP-Solution: https://github.com/fercavi/webdav

I installed an app that provides a link, called shared path. It is immature, but it does provide a functional URL if you share a link to a file.

Was this page helpful?
0 / 5 - 0 ratings