python - 安装的 pyocclient 得到 AttributeError: module 'owncloud' has no attribute 'Client'
问题描述
我正在尝试使用pyocclient
包将 owncloud 集成到我的 django 网站中。我使用它安装了它,pip install pyocclient
然后我从他们的文档中尝试了这个示例代码,但得到了owncloud没有attr的错误Client
这是我的代码
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'
这是 pyocclient 的 github 链接https://github.com/owncloud/pyocclient
如果有任何替代方法可以在没有 pyocclient 的情况下在我的 django 网站上上传、共享文件,它也可以帮助我。谢谢!
解决方案
推荐阅读
- python - 将数据添加到 txt 文件(并将其保存在那里)
- oracle-apex - SSO 回调配置
- python - 在 if-else 块中使用 try-except
- android - 安卓。从服务启动 Activity
- perl - 将从文本文件读取的行存储到 Perl 脚本中的变量
- swift - 为什么 SwiftUI 会对 Published 中的 willSet 做出反应
- react-native - 检查反应本机应用程序中的 ui 元素
- elasticsearch - 弹性搜索按布尔字段排序
- xpath - 如何根据xpath中同一行中另一个td的文本选择一个td值
- reactjs - ReactJS - 使用 useState 挂钩维护数值