-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement: thumbnails support #94
Comments
This sounds like a possibility for a feature. I might consider looking at a plugin mechanism and taking this on. Thanks for taking an interest! As an aside, I've just started work on a lighttpd example too: https://github.com/dom111/webdav-js/tree/feature/lighttpd-example |
I already see that next plugin will be a media player :) I searched for any existing file managers and looks like there is a plenty of them https://dev.to/plazarev/10-javascript-file-manager-libraries-to-consider-1nd5 And now I think that maybe it should be done in another way: try to add the WebDAV protocol support to existing file managers. For example here is a Backend PHP script for mootools-filemanager: https://github.com/cpojer/mootools-filemanager/tree/master/Assets/Connector How do you think, will it be better to go from the other side? Still there is a question how it will be comfortable or not to use the WebDAV because of it's limitations. For example Delete file or Move to Trash? What about folder sorting? And many other questions. The NextCloud for example uses API which is a WebDAV based but with many their own extensions. |
I happened across this interesting project. :) I am the lighttpd developer who wrote the current version of lighttpd mod_webdav. If you have suggestions for lighttpd mod_webdav (and those suggestions conform to the WebDAV spec), please ping me. (In the past, I have tried to get NextCloud and OwnCloud to add X-Sendfile support, but they both balked. lighttpd mod_webdav can be much faster due to not having the PHP overhead of NextCloud or OwnCloud.) |
Hi @gstrauss thank you for lighttpd. Speaking about the thumbnails generation discussed here it would be great to have hooks on file upload. Maybe inotify can be used for this but I don't khow how to deal with it and not sure if it may work on OpenWrt. |
Yes, inotify is an option in the application. Yes, inotify works on local filesystems under OpenWRT. My first impression to your comment is that adding shell-outs to a high performance server (lighttpd) is not the best idea. Instead, you can implement your own "triggers" using lighttpd mod_magnet and a few lines of custom lua. If the lua script detects an image upload -- e.g. when lighttpd is sending a 201 Created or 204 No Content response to a PUT request which successfully uploaded an image -- then the lua could send a request to a local daemon on the system to do additional processing (or the lua could fork) for thumbnail generation. |
Thank you. Looks like I have to create a hook in |
I think that you might be trying to do too much inside lighttpd.
I responded that you can implement the "hook" using lighttpd mod_magnet. I did not mean to suggest that you should implement EVERYTHING in the lua script. Here is (untested) lua code to sketch that out, which should be workable in lighttpd 1.4.60 or later. This is much more customizable to your application, works in lighttpd today, and is faster than executing a shell script (and for which I would have to write a new generic hook inside lighttpd mod_webdav).
All the code up to checking whether or not the thumbnail exists runs inside lighttpd and is very, very fast -- much faster than running a shell script only to find that the thumbnail already exists. Once it is determined that the thumbnail needs to be created, then a trigger or signal is sent, either to a standalone daemon to create the thumbnail, or by forking and execing a script to create the thumbnail. (If you're going to be running a daemon to monitor filesystem paths with inotify, then that daemon instead could listen for trigger signals (socket connection and request) from the lua script, rather than forking and execing from inside lighttpd.) |
Reviewing the above, if thumb-trigger.lua detects a successful PUT request (201 or 204) for an image file, then there is no need to check if the thumbnail already exists because the thumbnail needs to be regenerated for the newly uploaded file. Therefore, the trigger should always be sent after a successful PUT for an image file for which you want thumbnails. |
I finally found a problem: the I'll try latter. Thank you anyway. For now I wrote a script that detects a new file upload: #!/bin/sh
inotifywait -e MOVED_TO /srv/disk/dav/|
while read path action file;
do
echo "new $path $action $file"
done |
Another alternative is to generate the thumbnail upon first access with something like:
|
Oh, by the way: my mistake: |
@stokito FYI: I wrote a wiki page with code describing how to use lighttpd mod_magnet and lua to write trigger functions, e.g. how to generate a thumbnail after a successful image upload. |
Thank you, I'll read. I'm not sure if it worth to use it here. The inotifytools takes 20kb of space which is not critical but still quite a lot. And it's an additional dependency. In the same time a hook on web server level gives more flexibility. For example on FS level we see only moved_to event instead of create. And we don't have headers like content type, user, etc. This makes the inotify solution much complicated. I feel that it's not a good idea to use Lua scripts and especially that are specific to the Lighttpd only. In ideal world I need some kind of CGI interceptor that works for the whole path. Such interceptor may, for example, add headers and perform some custom authorization. I'll think about this latter. |
All that CGI info is available to and can be manipulated with lua in lighttpd mod_magnet, but yes, it would be a lighttpd-specific enhancement to webdav-js. As you found, the inotifytools is relatively small and seems like a better fit to work independently with multiple webservers and with multiple alternative upload methods (e.g. SFTP) If that is not good enough, then before writing your own CGI, you might look at other heavyweight server-side solutions: owncloud or nextcloud might be worth a look. I think both use SabreDAV. |
Hey @stokito, I'm considering breaking out the current list view into an optional package (included by default in the bookmarklet/examples) and making a tile view (which would easily allow thumbnail support when combined with something like the above script. I'll update here when I've made a start! Appreciate your input on this too @gstrauss! Thanks both, Dom |
I have a router with connected SSD. And there installed lighttpd + webdav. Now I wish to use the webdav share instead of Google Photos for my family. I've put the webdav.js there and now my wife can see list of photos just from her iPhone. But ideally she also needs to see small miniatures i.e. thumbnails.
There is a spec for "external thumbnails" where there are stored into a hidden folder
.sh_thumbnails
. You may generate it with the script https://github.com/stokito/genthumbs/tree/posixIt's not widely supported yet because of chicked-egg problem but I believe that the webdav-js can do this easily.
If the
.sh_thumbnails
folder exists then the webdav-js may try to load a thumbnail from it,Will you accept a PR with the feature?
I may not have enough time so if you are interested in the feature you may mark it as "help needed" and maybe someone else will be interested too,
The text was updated successfully, but these errors were encountered: