已安装的pyocclient获得AttributeError:模块“owncloud”没有属性“Client”

2024-06-17 10:47:34 发布

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

我正在尝试使用pyocclient包将owncloud集成到我的django网站中。我使用pip install pyocclient安装了它,然后从他们的文档中尝试了这个示例代码,但得到的错误是owncloud没有attrClient

这是我的密码

from django.contrib.auth.decorators import login_required
import owncloud

@login_required
def index(request):
    if request.method == "GET":
        return render(request, 'home.html')
    else:
        f = request.POST['file'] # a txt file
        public_link = 'https://lblostenzexxx.owncloud.online/index.php/x/3'

        oc.login('uid', 'password')
        oc.mkdir('testdir')
        oc.put_file(f, 'localfile.txt')
        link_info = oc.share_file_with_link(f)
        print(link_info.get_link())
        return render(request, 'home.html', {'msg':"return"})

以下是控制台错误:

System check identified no issues (0 silenced).
May 30, 2021 - 03:30:14
Django version 3.1.5, using settings 'owncloud.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[30/May/2021 03:30:14] "GET / HTTP/1.1" 200 1084
[30/May/2021 03:30:14] "GET /static/css/login_signup.css HTTP/1.1" 200 2813
Internal Server Error: /
Traceback (most recent call last):
  File "C:\Users\mhashirhassan22\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
  File "C:\Users\mhashirhassan22\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\mhashirhassan22\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\contrib\auth\decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "D:\Work\Others\Upwork\owncloud\owncloud\users\views.py", line 13, in index
    oc = owncloud.Client.from_public_link(public_link)
AttributeError: module 'owncloud' has no attribute 'Client'

这是pyocclienthttps://github.com/owncloud/pyocclient的github链接

如果有其他方法可以在我的django网站上不使用pyocclient上传、共享文件,它也可以帮助我。谢谢大家!


Tags: djangoinpyindexreturnresponserequestline