Core: Sharing files by direct link

Created on 20 May 2015  路  31Comments  路  Source: owncloud/core

I'm looking for a way to use the owncloud sharing to add pictures to forums, discussion boards and similar stuff. I'm able to extract the link like
http://localhost/index.php/apps/files_sharing/ajax/publicpreview.php?x=1596&y=979&a=true&file=%25D0%2591%25D0%25B5%25D0%25B7%25D1%258B%25D0%25BC%25D1%258F%25D0%25BD%25D0%25BD%25D1%258B%25D0%25B9.png&t=6s0x3RfjZY1C6lD&scalingup=0 but it is not usable on most forums since it has invalid extension. Would be perfect to have it translated to something more simple like http://localhost/index.php/apps/files_sharing/6s0x3RfjZY1C6lD/picture.png
For now I have to use all those adware picture hosting sites.

Please consider adding this feature.

enhancement sharing statuSTALE

Most helpful comment

There is a solution for Files already. Someone just needs to make ShareLinks compatible with the new sidebar found in 8.2+. It's an app, anybody can decide whether they need the feature or not. It connects to an official route part of the Gallery app, so it's tested with every release. There is no need to add anything to core at this stage.

All 31 comments

@LukasReschke @jancborchardt Wasn't there a similar proposal somewhere? I couldn't find it anymore.

Somehow slightly related to #1167 where the filename inside the URL is also mentioned

The thing is that the files are actually shared at the moment, but the link is very much hidden and the actual url is very "bad" and cannot be used on many forums. And with just a minor rework it would do what ppl expect.
Another thing to consider is an optional support for http://wiki.nginx.org/XSendfile for the sake of lowering load on php interpreter.

Another thing to consider is an optional support for http://wiki.nginx.org/XSendfile for the sake of lowering load on php interpreter.

I think this is already supported. see https://github.com/owncloud/core/pull/13060/files

In theory you could also use the "public.php/webdav" endpoint. This would deliver the real file (not a reduced version). But note that this endpoint might be disabled if server to server sharing (aka federation) is disabled, as it is mainly used by that.

CC @oparoz @georgehrke for preview stuff

@non7top - I don't understand why you don't use the shared link provided by the share dropdown and add /download at the end.

https://oc8demo.interfacloud.com/index.php/s/pvetv4RaIbFhDRb/download

If I use this in Github
Sample pic

Caveats

  • Only works for browser supported media types
  • Does not resize the original picture

Because many discussion boards out there simply check the url for valid picture extension. If none found they will reject inserting such image, regardless of whether the link actually points to a valid image or not. And the link you provided is not displayed as picture in browser so it is counterintuitive to use it as a picture.

Thanks!
I think the best things to do would be to have an app which can generate such links. Maybe a plugin for Gallery.

There is no plugin that currently do that?
The API we can do this?
Class SHARE: http://api.owncloud.org/classes/OCP.Share.html

The easiest way to do this would probably to have an app which simply re-routes the short URL to the long one.
The hardest part would then be to create the interface which allows the user to collect the short URL.

Linking directly to an image seems to be a core function of a sync & share software. Not just something which is an extension of the Gallery app.

I agree, but the problem is that it will probably take a long time to land, simply because the share API has to be upgraded to generate different public links for single files which are not password protected.

The app route offers more flexibility, you could even extend it to the point where you have your own cloudconvert service available locally.

@jancborchardt I agree... however how would this work UI wise?

@oparoz well that part _should_ be doable. However, if a separate app is used you are stuck with on earth you get the direct url to the user. If users have to open up a separate app for that to convert the url I doubt that would be of much help.

There is however an issue with what do you use as new url? Since you probably do not want to use the filename as that might change over time.

@rullzer similar to the current 禄Direct link芦 input below the image in a public share. We can even do some nice 禄copy link芦 stuff with HTML lately: http://updates.html5rocks.com/2015/04/cut-and-copy-commands

@rullzer - You hijack the share dialogue and use the appropriate URL depending on what is shared.
As for the URL, something like this would always work.
/index.php/apps/smartlink/s/pvetv4RaIbFhDRb.png

I've just tried to share a single media file on dropbox and they include the full filename in the link, but if you rename the file, the user gets a 404 and that's really bad imho, so we should try to do better, maybe like my suggestion above.

@non7top @mrladeia I've added a way to add extensions to links. Everything is described here:
https://github.com/owncloud/galleryplus/issues/156

You'll need to use the master version of Gallery. Simply download the zip file from the right sidebar if you don't want to use git.

Make sure to try as many different forums as you can :)

@oparoz of course - if anything the filename should just be a nice addition to the link to make it readable. Nothing required. If the filename is changed, the URL would just change dynamically. The only thing required is the unique code in the link which points to the file.

Could we not just append the file name. And if it changes throw back a 307 with the correct file name? Just to make it a bit nicer?

My endpoint uses whatever the link uses, but I'm not sure it makes much of a difference if the file is posted on Imgur, etc. No?
My Share Links app is using the file ID. That way it's never impacted by the name change

@rullzer yeah, that鈥檚 what I meant. The file ID is used as definite identifier, but the file name is added to make the URL more readable. It can safely be cut and the same file will be shown.

It's not possible to link images so that they become embedded in forum posts afaik. That would be a great enhancement imho.

In forums

Don't work:
https://en0ch.se/index.php/s/8wnzgLI9KeyQEdg

Works:
http://i.imgur.com/Z0h8GdX.png

Does this work ? https://en0ch.se/index.php/s/8wnzgLI9KeyQEdg/download

Nope. We always send a header to mark this as download and not as inline view. There are security problems with this, because then you can share a JS file and use this to inject code, because it is from the same domain. We would need to have a separat (sub-) domain to get the shares from. Or ask @LukasReschke about this ... he has also already headaches because of this :stuck_out_tongue_closed_eyes:

Wouldn't it be easy to mark as inline-view pictures according to their mime-types ?
I mean, having a mime-type list of all known picture formats, or even simply of most used formats (jpg, png, gif, bmp, svg, maybe others) isn't really a hassle.

The download.php class already gets the mime-type of the file, having it set inline-view for all "image/*" ones wouldn't be a great issue.
And I don't really see how this would affect safety.

There is a solution for Files already. Someone just needs to make ShareLinks compatible with the new sidebar found in 8.2+. It's an app, anybody can decide whether they need the feature or not. It connects to an official route part of the Gallery app, so it's tested with every release. There is no need to add anything to core at this stage.

I also want to make wget working for shared links, that would be awesome! Then I could share files from my cloud, and use them in the scripts for the VM.

EDIT: This is not just a feature for pictures, I think it should be implemented on _all_ the shared links. As it is right now, trying to download with wget gives me a HTML document.

@enoch85 curl -J -O $url might do. Use the URL with the appended "download" at the end.

But yeah, would be good if the UI would provide a URL containing the actual file name.

@PVince81 Thanks! That worked. :+1:

Is there any progress on this? Has anyone written a plugin or something similar?

@KarlBaumann , @oparoz has added some functionality in Gallery Plus, linked a few comments above. Works well enough with _some_ services, not all of them sadly.

Was this page helpful?
0 / 5 - 0 ratings