Skip to content
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

Can't access files on Netfile #134

Open
beccon4 opened this issue Oct 26, 2022 · 0 comments
Open

Can't access files on Netfile #134

beccon4 opened this issue Oct 26, 2022 · 0 comments

Comments

@beccon4
Copy link

beccon4 commented Oct 26, 2022

I try to download a file from a Netfile "Data Room" which is a WebDAV share. The URL is https://webdav.netfiles.de//projectfiles. When using other WebDAV clients such as Gnome's Files application, I am able to list the directory and upload/download files. Unfortunately doing so using webdav4 fails.
I can show the file content (ls) but when trying to access that file I get a "not found" error:

#!/bin/python3
from webdav4.client import Client
netfile_client = Client("https://webdav.netfiles.de/***changed***/projectfiles", auth=("myemail@address.xy", "secret"))

print ("This works: client.ls('/hallo.txt') " , netfile_client.ls("/hallo.txt"))

print ("This fails: client.content_type('/hallo.txt')" , netfile_client.content_type("/hallo.txt"))

results in:

$ ./get_netfiles.py 
This works: client.ls('/hallo.txt')  [{'name': 'hallo.txt', 'href': 'https://webdav.netfiles.de/***changed***/projectfiles/hallo.txt', 'content_length': 12, 'created': datetime.datetime(2022, 10, 26, 15, 46, 10, tzinfo=tzutc()), 'modified': datetime.datetime(2022, 10, 26, 15, 46, 10, tzinfo=datetime.timezone.utc), 'content_language': None, 'content_type': 'text/plain; charset=utf-8', 'etag': '"36b787591eb370bb0c9047dc1e2e6e20"', 'type': 'file', 'display_name': 'hallo.txt'}]
Traceback (most recent call last):
  File "/home/beccon/Python/./get_netfiles.py", line 9, in <module>
    print ("This fails: client.content_type('/hallo.txt')" , netfile_client.content_type("/hallo.txt"))
  File "/usr/local/lib/python3.10/dist-packages/webdav4/client.py", line 581, in content_type
    return self.get_props(path, "content_type").content_type
  File "/usr/local/lib/python3.10/dist-packages/webdav4/client.py", line 334, in get_props
    result = self.propfind(path, headers=headers, data=data)
  File "/usr/local/lib/python3.10/dist-packages/webdav4/client.py", line 318, in propfind
    http_resp = self.with_retry(call)
  File "/usr/local/lib/python3.10/dist-packages/webdav4/func_utils.py", line 44, in wrapped_function
    return func()
  File "/usr/local/lib/python3.10/dist-packages/webdav4/func_utils.py", line 68, in wrapped
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/webdav4/client.py", line 365, in _request
    raise ResourceNotFound(path)
webdav4.client.ResourceNotFound: The resource /hallo.txt could not be found in the server

The same happens when I use the cli command dav.

For some strange reason everything works fine when I connect to Nextcloud. There I can list the directory, show file attributes, upload and download:

./get_nextcloud.py 
This works [{'name': 'hallo.txt', 'href': '/nextcloud/remote.php/dav/files/test001/hallo.txt', 'content_length': 17, 'created': None, 'modified': datetime.datetime(2022, 10, 26, 17, 55, 57, tzinfo=datetime.timezone.utc), 'content_language': None, 'content_type': 'text/plain', 'etag': '"dbcd4f45a05b94992167db7b36b0838b"', 'type': 'file', 'display_name': None}]
This works also text/plain
Upload
Download

An interesting difference is that in Nexcloud the href does not contain an FQDN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant