使用Python将图像上载到WebDav服务器

2024-05-23 14:38:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将图像上载到WebDAV服务器。服务器托管在Linux服务器上,我们可以使用URL在WebDAV服务器中显示图像。我只是想做一个简单的上传

from webdav3.client import Client

options = {
    'webdav_hostname': "http://www.link.com/webdav/",
    'webdav_login': "user",
    'webdav_password': "user"
}

if __name__ == '__main__':
    client = Client(options)
    client.upload_file(remote_path='blank.php/webdav/converted_images',
                       local_path="../Downloads/download.jpeg")

我得到以下错误:

    Traceback (most recent call last):
  File "/home/user/webDav_test/test.py", line 30, in <module>
    local_path="../Downloads/download.jpeg")
  File "/home/user/.local/lib/python3.7/site-packages/webdav3/client.py", line 70, in _wrapper
    res = fn(self, *args, **kw)
  File "/home/user/.local/lib/python3.7/site-packages/webdav3/client.py", line 491, in     raise RemoteParentNotFound(urn.path())
webdav3.exceptions.RemoteParentNotFound: Remote parent for: /webdav/converted_images not found

Tags: pathinpy图像服务器clienthomelocal