dom111 / webdav-js

A simple WebDAV client written in JS for use as a bookmarklet, or integration into a web server.
MIT License
91 stars 18 forks source link

Use XMLHttpRequest for file uploads (PUT method) to show progress indicator #115

Open Lex-2008 opened 1 year ago

Lex-2008 commented 1 year ago

Hi!

First, thanks for a nice project! I like how I can have an otherwise static (looking) website but easily turn it into a file manager with a click of a button.

However, I noticed that it lacks any upload progress indicator, which might be an issue when uploading a gigabyte-sized files via not-so-fast connection.

Probably that's because underlying fetch API doesn't support it.

It looks like a suggested workaround is to use "good ol' XMLHttpRequest". In a quick test, I was able to use it to issue a PUT request to upload a file to my webdav server (running nginx) while monitoring progress in console.

What do you think about it? I see that file upload logic is located in a separate file, so it should be possible to change even for me.

Would you be interested in such pull request, or would you prefer to do it yourself?

dom111 commented 1 year ago

Hi there,

Thanks for taking interest and raising an issue!

I'd certainly be open to a PR if you have the time!

Hopefully the dev env all makes sense and the tests work 😅

Feel free to assign an issue to yourself and work against that, please ask if you have any questions and if you don't end up having time, I'll try and take a look next time I do.some updates here!

Thanks,

Dom

Lex-2008 commented 1 year ago

I'm not sure I can assign myself to an issue - likely I lack some permissions...

But I played with gitpod - it was very nice and gave me a working env! I just only had to figure out that to rebuild project I have to run make build inside the terminal, and cleanup dist dir - for some reason, it had webdav.css and webdav.js dicrectories, and wasn't writeable for current user.

Anyway, I made it work and created PR: https://github.com/dom111/webdav-js/pull/116 - please let me know what you think about it!

Note that it was my first ever experience in writing TypeScript, so feel free to correct me!

dom111 commented 1 year ago

Hey @Lex-2008, this is looking great so far, thanks for the contribution! No concerns over the TypeScript, couple of minor comments but as noted on the PR, if you don't have time/inclination, there's enough there for me to move bits around and merge as time allows.

Thanks again for your time on this!

Lex-2008 commented 1 year ago

Thanks for warm welcome!

It's pretty interesting for me to work on it (new language, new editor, new everything), so I'd like to work on this a bit more - for as long as my gitpod credit lasts, at least :D