You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to download a .txt file from my cloud I got the error KeyError: 'content-length'. Actually it worked with .txt files with less than exactly 256 characters. Other file types (such as .png, .jpeg, .mp3, .csv) worked just fine. It did not matter of which format the local file was (so even that client.download_file('/publish/_testing/test', 'tmp/test.txt') worked.
File "my_file.py",
line 36, in <module>
print(client.download_file('/publish/_testing/test.txt', 'tmp/test.txt'))
File "webdav3\client.py", line 67, in _wrapper
res = fn(self, *args, **kw)
File "webdav3\client.py", line 458, in download_file
total = int(response.headers['content-length'])
File "requests\structures.py", line 52, in __getitem__
return self._store[key.lower()][1]
KeyError: 'content-length'
The text was updated successfully, but these errors were encountered:
The problem is that in the download_file function in client.py the execute_request function delivers a header without a 'content-length' entry for .txt-files with more than 255 characters. To prevent the script from failing due to this error, you could add an exception like this:
with open(local_path, 'wb') as local_file:
response = self.execute_request('download', urn.quote())
try:
total = int(response.headers['content-length'])
except:
total = None
current = 0
When trying to download a .txt file from my cloud I got the error
KeyError: 'content-length'
. Actually it worked with .txt files with less than exactly 256 characters. Other file types (such as .png, .jpeg, .mp3, .csv) worked just fine. It did not matter of which format the local file was (so even thatclient.download_file('/publish/_testing/test', 'tmp/test.txt')
worked.Code:
client.download_file('/publish/_testing/test.txt', 'tmp/_local_test.txt'))
test.txt:
testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest
Error:
The text was updated successfully, but these errors were encountered: