一个集成SDK的工具库,如百度云盘API
Project description
SDK Utils
一个用于SDK开发的工具库,提供构建Python SDK的通用功能。目前主要封装了百度云盘的常用操作,使开发者能够轻松地在自己的应用中集成百度云盘功能。
安装方法
pip install sdk_utils
主要功能
- 百度云盘API客户端
- 文件上传、下载、分享、移动、复制、删除等基本功能
- 目录操作、文件搜索和大文件分片上传等高级功能
- OAuth2.0授权认证流程
- API客户端工具
- 认证辅助工具
- 速率限制和重试机制
- 响应解析和错误处理
- 日志记录和调试工具
使用示例
百度云盘客户端
from sdk_utils.baidu_cloud import BaiduCloudClient
# 创建百度云盘客户端
client = BaiduCloudClient(
app_key="your_app_key",
secret_key="your_secret_key",
access_token="your_access_token", # 可选,如果已有token
refresh_token="your_refresh_token" # 可选,用于自动刷新token
)
# 获取授权URL(如果没有access_token)
auth_url = client.get_auth_url(redirect_uri="http://localhost:8000/callback")
print(f"请访问此URL进行授权: {auth_url}")
# 通过授权码获取token
token_info = client.get_access_token(code="authorization_code", redirect_uri="http://localhost:8000/callback")
# 上传文件
result = client.upload_file(local_path="/path/to/local/file.txt", remote_path="/apps/your_app/file.txt")
# 下载文件
client.download_file(remote_path="/apps/your_app/file.txt", local_path="/path/to/save/file.txt")
# 获取文件列表
file_list = client.list_files(dir_path="/apps/your_app")
for file in file_list:
print(f"文件名: {file['server_filename']}, 大小: {file['size']}")
使用bypy封装的百度云盘工具
from sdk_utils.baidu_cloud_bypy import BaiduPanTools
# 创建工具实例(首次使用会自动进行授权)
pan = BaiduPanTools()
# 上传文件
pan.upload_file("test_upload.txt")
# 下载文件
pan.download_file("test_upload.txt", "downloads")
# 查看文件列表
file_list = pan.list_files()
print(file_list)
# 同步整个文件夹
pan.sync_folder("local_folder", "remote_folder")
文档
完整文档请访问我们的文档站点。
开发文档
如果您想参与开发,请查看开发者指南了解更多信息。
贡献
欢迎贡献代码!请随时提交Pull Request。
贡献步骤:
- Fork 项目仓库
- 创建功能分支
- 提交变更
- 运行测试确保通过
- 提交 Pull Request
许可证
本项目采用MIT许可证 - 详情请参阅LICENSE文件。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sdk_utils-0.1.2.tar.gz
(65.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sdk_utils-0.1.2.tar.gz.
File metadata
- Download URL: sdk_utils-0.1.2.tar.gz
- Upload date:
- Size: 65.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5eeba0fb5b9eab6f183f16d6ec493eebbb2793288bf6fcaec6952f76c71b5f8
|
|
| MD5 |
7616e9c1472182e98e7dcbf1e4e79d5b
|
|
| BLAKE2b-256 |
27eb8356890adafdaf7c9beb4a9ef106f2bfe3033dc17b02ca6583c84533371d
|
File details
Details for the file sdk_utils-0.1.2-py2.py3-none-any.whl.
File metadata
- Download URL: sdk_utils-0.1.2-py2.py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8733a537c4e0042a0d935d505c3eecca999345b5d976590f813999ccf1ff2880
|
|
| MD5 |
28c6273dd421edf973fde0b242db31ec
|
|
| BLAKE2b-256 |
0b89abc307f59108a76cbbfd83746e76faba33fa886fa7533409033aa0c5d869
|