首页 > 解决方案 > 使用 Python 将图像上传到 WebDav 服务器

问题描述

我正在尝试将图像上传到 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

标签: pythonimagefile-uploadwebdav

解决方案


推荐阅读