thephpleague / glide

Wonderfully easy on-demand image manipulation library with an HTTP based API.
http://glide.thephpleague.com
MIT License
2.55k stars 198 forks source link

Support for symlinks #254

Open Crell opened 5 years ago

Crell commented 5 years ago

Is there a reason that symlinks are disabled?

Specifically, FlySystem defaults to disallowing Symlinks:

https://github.com/thephpleague/flysystem/blob/master/src/Adapter/Local.php#L75

When Glide creates a Local file system in its server, it leaves the default value:

https://github.com/thephpleague/glide/blob/master/src/ServerFactory.php#L81

Net result: there's no way to use a symbolic link with Glide, period (as far as I can tell). This is a problem, at least for me, since that's exactly what I'm trying to do. Bummer.

I propose that either: 1) The call be modified to allow symlinks. 2) The config array be modified to include a parameter to allow symlinks. (Probably just a parameter that gets passed to Local directly as that argument, so you can set whatever value you want to it.)

I can work on a PR for either if the maintainer(s) green light it.

reinink commented 5 years ago

Interesting! I don't really see any reason why symbolic links couldn't be allowed, especially since Glide operates in a read-only manner. @frankdejonge, do you see any concerns with updating Glide to allow symlinks?

Also @Crell, FWIW, you can always update your config to pass in your own Flysystem instance, with this configured properly. Maybe a good place to start simply to verify that it works?

frankdejonge commented 5 years ago

The root of a filesystem can be a symlink, that's not a problem. But within the root you can't have symlinks because it's not a transferrable concept for cloud providers.

frankdejonge commented 5 years ago

@Crell could you elaborate about your case for using symlinks? Most often there's easy ways around it and root level symlinks are fine.

Crell commented 5 years ago

I'm building a simple read-only photo gallery that operates on a "huge mass of image files in a tree" and using Glide for image resizing. I have a big many-GB archive of images that I want to be browsable, but I also want to have "album" directories that are a directory of symlinks to other files. That allows me to curate highlights that appear as a new album.

Think 10 directories of "European Vacations", and then an Album of "Cool Cathedrals" that has symlinks to the best cathedral picture from each city. (Which... is pretty much exactly what I'm trying to do. :smile: ) That will involve multiple layers of symlinks to setup, which in concept should be fine to do.

@reinink Thanks for the tip on a custom FlySystem instance. I tried, it though, and it looks like your only options are silently skipping symlinks and throwing an exception. Those are the two possible constants and passing a 0 (neither constant) behaves like a skip. So this may be a Flysystem issue more than a Glide issue. :frowning_face:

I'm not sure what "transferrable concept for cloud providers" has to do with it...