一个集成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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
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.1-py2.py3-none-any.whl.
File metadata
- Download URL: sdk_utils-0.1.1-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 |
d98aad03b92e0cbb6bec14989018661d59c0114262ee7ce24e3a8cf0622f5f74
|
|
| MD5 |
2d5c8cfef3c393a175ffb9ade1ea26bf
|
|
| BLAKE2b-256 |
4d41829643a8131c437ebad6b415c256cb717eaf62e3b446c463aae3321324ae
|