NextCloud + python API

NextCloud库地址:https://github.com/matejak/nextcloud-API
库方法官方文档:https://nextcloud-api.readthedocs.io/en/latest/api_wrappers.html
安装库依赖:

安装库:

建议在虚拟环境下使用
使用示例:

# -*- coding: utf-8 -*-
from nextcloud import NextCloud

NEXTCLOUD_URL = 'http://localhost:8080/'
NEXTCLOUD_USERNAME = 'admin'
NEXTCLOUD_PASSWORD = 'admin'
to_js = True
nxc = NextCloud(endpoint=NEXTCLOUD_URL, user=NEXTCLOUD_USERNAME, password=NEXTCLOUD_PASSWORD, json_output=to_js)
# 获取用户的列表
a = nxc.get_users()
print(a.data)


# 获取用户的文件夹信息
c = nxc.list_folders('YunOfWx')
# print(c.data)

# 上传图片,需要在服务器对应目录下设置文件名
local_filepath = 'test.png'
upload_filepath = 'many/hhh.png'
#
b = nxc.upload_file('YunOfWx', local_filepath, upload_filepath)
print(b.data)

# 分享图片拿到公共链接
d = nxc.create_share('many/hhh.png', 3)
print(d.data)
# 下载图片
a = nxc.download_file("hhh", "Photos/图片1.png")
posted @ 2021-10-29 11:24  CuriosityWang  阅读(862)  评论(0编辑  收藏  举报