-
Notifications
You must be signed in to change notification settings - Fork 662
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
add file upload support for webdav #1743
Conversation
Many thanks for your PR. It seems to double with #1404 which adds Nextcloud upload support as well, along with generic WebDAV upload. Could you review whether this fully includes your suggested changes? Since @DavHau gave permissions to continue with his/her work, are you willing to continue with it, e.g. recreating your PR with WebDAV support added as well and rebasing on current |
Thank you for considering. I'm on the phone now. I'll look into #1404 beginning of the week |
What I like about this PR compared to #1404 is that it only touches relevant code parts and that it does not add another 3rd party dependency. The benefit of #1404 is that it adds a generic WebDAV upload service and Nextcloud only as a small abstraction of it. I'm not 100% sure whether there is anything special about Nextcloud's WebDAV endpoint, but I'm not aware of any and hence it should be similarly possible here simply by allowing to change the endpoint URL. This would increase the value massively. Btw, not all Nextcloud instances run on the webroot, mine runs on To put things together:
|
I'll test this PR now, @manzari many thanks for the rebase 👍. |
I would encourage the community to get the code to pass all the bandit rules. |
The two mentioned ones cannot be solved, the |
Right, EDIT: Solved! |
There is a general issue with the "Server Address" input here: The tooltip states to use the plain IP or hostname. But the code currently expects a protocol/scheme. Since WebDAV endpoints can be reachable via HTTP or HTTPS, we cannot auto-add the protocol/scheme like it is possible with other upload services. I see two options:
|
Upload works well when using the full endpoint URL with trailing slash as "Server Address" and full path with leading slash as "Location". The port is currently not used, but it should. However, to avoid all this confusion between URL, hostname, port, endpoint path, location etc etc, we really should use an "Endpoint URL" input field, with contains scheme/protocol, hostname, in case port, path to endpoint. The "Location" as dedicated input makes sense, if we want to be able to pre-create this root directory. But we could also have it added together with the endpoint URL, adding the info that this path needs to exist already. Btw, since a simple |
I'd suspect it to be somewhat restricted to WebDAV (which I'm not familiar with). At least MKCOL is not a valid HTTP request method (like PUT, DELETE etc) |
2269b85
to
7f9113f
Compare
Addressed reviews. Last thing is a formal step now, renaming the "server address" input to "WebDAV endpoint URL", which implies a new additional setting to be saved to the camera config. But the server address tooltip currently shows the wrong info that only the hostname or IP is required, while the full WebDAV endpoint URL is required. |
b64encode takes and returns only bytes, so the credentials need to be byte-encoded first and the returned bytes object decoded afterwards (ASCII works for base64 strings). Additionally some %-formattings have been replaced with f-strings, fix some syntax errors and satisfy pre-commit black checks.
Remove unused port variable and GUI input. Update urllib calls for new selective imports. Always strip and re-add slashes from path elements so assure there is always exactly one slash between them. Signed-off-by: MichaIng <[email protected]>
c98e218
to
66cd69e
Compare
I merged the endpoint URL setting with the one for S3 uploads, but wanted to show a different tooltip making use of the "depends" attribute. But sadly this doesn't work since in the JavaScript it is only interpreted for "tr" elements and I don't want to add the additional overhead for now to loop through all tooltips as well. To safe to the same setting, when using two dedicated input boxes, they need to have the same DOM ID. |
Okay, works well now 🙂. I'll merge in a few hours if no objections. |
since the whole URL is required, not only the IP or hostname. Merge with S3 endpoint URL setting and extend the tooltip to show examples for both upload services.
Hello,
this is an UploadService implementation for nextcloud.
The requests for uploading files as well as the ones used for creating and deleting directories are documented here.
Also I can provide nextcloud accounts for testing, just pm me.
I hope you like it :)