Bitzsoft.Integrations.CloudDrive.Baidu
1.0.0-alpha.8
This is a prerelease version of Bitzsoft.Integrations.CloudDrive.Baidu.
dotnet add package Bitzsoft.Integrations.CloudDrive.Baidu --version 1.0.0-alpha.8
NuGet\Install-Package Bitzsoft.Integrations.CloudDrive.Baidu -Version 1.0.0-alpha.8
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bitzsoft.Integrations.CloudDrive.Baidu" Version="1.0.0-alpha.8" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bitzsoft.Integrations.CloudDrive.Baidu" Version="1.0.0-alpha.8" />
<PackageReference Include="Bitzsoft.Integrations.CloudDrive.Baidu" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bitzsoft.Integrations.CloudDrive.Baidu --version 1.0.0-alpha.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Bitzsoft.Integrations.CloudDrive.Baidu, 1.0.0-alpha.8"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bitzsoft.Integrations.CloudDrive.Baidu@1.0.0-alpha.8
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bitzsoft.Integrations.CloudDrive.Baidu&version=1.0.0-alpha.8&prerelease
#tool nuget:?package=Bitzsoft.Integrations.CloudDrive.Baidu&version=1.0.0-alpha.8&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Bitzsoft.Integrations.CloudDrive.Baidu
百度网盘服务实现,基于百度网盘开放平台 API。
功能
- 基于百度网盘开放平台 API,支持文件上传、下载、列表查询和文件夹管理
- 认证方式:OAuth 2.0 访问令牌,支持令牌自动刷新
- 大文件分块上传(precreate/chunks/create 三步流程)
- 文件管理(复制、移动、删除)
- 文件搜索(递归搜索)
安装
dotnet add package Bitzsoft.Integrations.CloudDrive.Baidu
<PackageReference Include="Bitzsoft.Integrations.CloudDrive.Baidu" Version="*" />
配置
{
"CloudDrive": {
"Baidu": {
"AccessToken": "通过 OAuth 授权码流获取的访问令牌",
"RefreshToken": "刷新令牌(可选,用于自动刷新)",
"AppKey": "应用 App Key(刷新令牌时需要)",
"SecretKey": "应用 Secret Key(刷新令牌时需要)",
"AppName": "百度网盘应用名称",
"BaseUrl": "https://pan.baidu.com/rest/2.0/",
"UploadBaseUrl": "https://d.pcs.baidu.com/rest/2.0/pcs/superfile2",
"TokenEndpoint": "https://openapi.baidu.com/oauth/2.0/token",
"LargeFileThreshold": 4194304,
"ChunkSize": 4194304,
"HttpClientName": "BaiduCloudDrive"
}
}
}
| 参数 | 必填 | 默认值 | 说明 |
|---|---|---|---|
AccessToken |
是 | -- | OAuth 2.0 访问令牌 |
RefreshToken |
否 | -- | 刷新令牌,配置后支持自动刷新 |
AppKey |
否 | -- | 应用 App Key,刷新令牌时需要 |
SecretKey |
否 | -- | 应用 Secret Key,刷新令牌时需要 |
AppName |
是 | -- | 百度网盘应用名称,用于拼接文件路径前缀 |
BaseUrl |
否 | https://pan.baidu.com/rest/2.0/ |
API 基地址 |
UploadBaseUrl |
否 | https://d.pcs.baidu.com/rest/2.0/pcs/superfile2 |
分块上传基地址 |
TokenEndpoint |
否 | https://openapi.baidu.com/oauth/2.0/token |
OAuth 令牌端点 |
LargeFileThreshold |
否 | 4194304(4MB) |
大文件分块上传阈值 |
ChunkSize |
否 | 4194304(4MB) |
分块上传每块大小 |
HttpClientName |
否 | BaiduCloudDrive |
命名 HttpClient 名称 |
注册
services.AddBitzsoftBaiduCloudDrive(configuration, "CloudDrive:Baidu");
或通过委托配置:
services.AddBitzsoftBaiduCloudDrive(options =>
{
options.AccessToken = "你的访问令牌";
options.RefreshToken = "你的刷新令牌";
options.AppKey = "你的应用 Key";
options.SecretKey = "你的应用密钥";
options.AppName = "你的应用名称";
});
第三方请求日志
内置 Bitzsoft.Integrations.RequestLogging 出站请求记录管道,默认 NullRequestLogStore 不持久化。
// ① 默认:启用记录管道但不持久化(日志丢弃)
services.AddBitzsoftBaiduCloudDrive(options => { /* ... */ });
// ② 持久化:宿主注册 IRequestLogStore 实现后,所有出站请求自动落库
services.AddRequestLogging<MyRequestLogStore>(opts =>
{
opts.MaxBodyLength = 8192; // 单条正文截断上限
opts.SensitiveFields.Add("mySecret"); // 额外脱敏字段
});
services.AddBitzsoftBaiduCloudDrive(options => { /* ... */ });
实现状态
| 方法 | 状态 | 说明 |
|---|---|---|
UploadAsync |
已实现 | 三步分块上传:precreate + chunks + create |
DownloadAsync |
已实现 | 两步下载:获取 dlink + 下载内容 |
DeleteFileAsync |
已实现 | filemanager?opera=delete |
MoveFileAsync |
已实现 | filemanager?opera=move |
CopyFileAsync |
已实现 | filemanager?opera=copy |
GetFileInfoAsync |
已实现 | multimedia?method=filemetas |
ListFilesAsync |
已实现 | /xpan/file?method=list,支持分页 |
CreateFolderAsync |
已实现 | /xpan/file?method=create&isdir=1 |
DeleteFolderAsync |
已实现 | filemanager?opera=delete |
SearchAsync |
已实现 | /xpan/file?method=search |
CreateShareLinkAsync |
不支持 | 需企业级开发者审批 |
DeleteShareLinkAsync |
不支持 | 需企业级开发者审批 |
GetPermissionsAsync |
不支持 | API 不支持独立权限管理 |
SetPermissionAsync |
不支持 | API 不支持独立权限管理 |
DeletePermissionAsync |
不支持 | API 不支持独立权限管理 |
ListVersionsAsync |
不支持 | API 不支持版本管理 |
DownloadVersionAsync |
不支持 | API 不支持版本管理 |
RestoreVersionAsync |
不支持 | API 不支持版本管理 |
注意事项
- 百度网盘要求文件路径必须以
/apps/{appName}/为前缀,AppName配置项用于指定应用名称 - 文件 ID 使用
fs_id(文件系统 ID)的字符串表示 - 访问令牌通过外部 OAuth 授权码流程获取,可配置 RefreshToken 实现自动刷新
- 大文件(超过 4MB 默认阈值)自动使用三步分块上传流程
- 下载文件需要两步操作:先获取下载链接(dlink),再通过 dlink 下载内容
依赖
Bitzsoft.Integrations.CloudDrive,企业网盘抽象层Bitzsoft.Integrations.Compatibility,基础工具库
相关包
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Bitzsoft.Integrations.CloudDrive (>= 1.0.0-alpha.8)
- Bitzsoft.Integrations.Compatibility (>= 1.0.0-alpha.8)
- Bitzsoft.Integrations.RequestLogging (>= 1.0.0-alpha.8)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Http (>= 10.0.9)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.9)
-
net5.0
- Bitzsoft.Integrations.CloudDrive (>= 1.0.0-alpha.8)
- Bitzsoft.Integrations.Compatibility (>= 1.0.0-alpha.8)
- Bitzsoft.Integrations.RequestLogging (>= 1.0.0-alpha.8)
- Microsoft.Extensions.Configuration.Abstractions (>= 5.0.0)
- Microsoft.Extensions.Http (>= 5.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 5.0.0)
-
net8.0
- Bitzsoft.Integrations.CloudDrive (>= 1.0.0-alpha.8)
- Bitzsoft.Integrations.Compatibility (>= 1.0.0-alpha.8)
- Bitzsoft.Integrations.RequestLogging (>= 1.0.0-alpha.8)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Http (>= 10.0.9)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.9)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Bitzsoft.Integrations.CloudDrive.Baidu:
| Package | Downloads |
|---|---|
|
Bitzsoft.Integrations.CloudDrive.All
企业网盘服务聚合包 — 包含所有供应商实现 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-alpha.8 | 40 | 7/1/2026 |
| 1.0.0-alpha.7 | 58 | 6/16/2026 |
| 1.0.0-alpha.6 | 62 | 6/16/2026 |
| 1.0.0-alpha.5 | 57 | 6/14/2026 |
| 1.0.0-alpha.4 | 42 | 7/1/2026 |
| 1.0.0-alpha.3 | 58 | 6/7/2026 |