![]() |
VOOZH | about |
dotnet add package TJC.Cyclops.CloudStorage --version 2026.6.11.2
NuGet\Install-Package TJC.Cyclops.CloudStorage -Version 2026.6.11.2
<PackageReference Include="TJC.Cyclops.CloudStorage" Version="2026.6.11.2" />
<PackageVersion Include="TJC.Cyclops.CloudStorage" Version="2026.6.11.2" />Directory.Packages.props
<PackageReference Include="TJC.Cyclops.CloudStorage" />Project file
paket add TJC.Cyclops.CloudStorage --version 2026.6.11.2
#r "nuget: TJC.Cyclops.CloudStorage, 2026.6.11.2"
#:package TJC.Cyclops.CloudStorage@2026.6.11.2
#addin nuget:?package=TJC.Cyclops.CloudStorage&version=2026.6.11.2Install as a Cake Addin
#tool nuget:?package=TJC.Cyclops.CloudStorage&version=2026.6.11.2Install as a Cake Tool
☁️ 统一云存储解决方案 ☁️
Cyclops.CloudStorage 是企服版框架中的云存储SDK,提供了统一的云存储访问接口,实现了阿里云、微软Azure和MinIO云存储服务的无缝集成。该项目采用工厂模式设计,使开发者能够使用统一的API访问不同的云存储服务,极大地简化了多平台云存储的开发工作。
ICloudStorageClient 接口,统一不同云存储服务的调用方式CloundStorageClientFactory 统一创建和管理云存储客户端实例dotnet add package TJC.Cyclops.CloudStorage
using Cyclops.CloudStorage;
// 方式一:使用配置对象创建
var options = new CloudStorageOptions
{
Id = "aliyun-access-key-id",
Key = "aliyun-access-key-secret",
SupplierType = EnumSupplierType.Aliyun,
ContainerName = "my-bucket",
Endpoint = "oss-cn-hangzhou.aliyuncs.com"
};
var client = CloundStorageClientFactory.Create(options);
// 方式二:从配置中心自动读取配置
var client = CloundStorageClientFactory.Create();
using Cyclops.CloudStorage;
// 从文件路径上传
await client.UploadAsync("remote-file.jpg", "local-file.jpg");
// 从流上传
using (var stream = new FileStream("local-file.jpg", FileMode.Open))
{
await client.UploadAsync("remote-file.jpg", stream);
}
using Cyclops.CloudStorage;
// 下载文件流(适合大文件)
using (var stream = await client.DownloadAsync("remote-file.jpg"))
{
if (stream != null)
{
using (var fileStream = new FileStream("downloaded-file.jpg", FileMode.Create))
{
await stream.CopyToAsync(fileStream);
}
}
}
// 下载文件内容(适合小文件)
var fileContent = await client.DownloadContentAsync("remote-file.jpg");
if (fileContent != null)
{
await File.WriteAllBytesAsync("downloaded-file.jpg", fileContent);
}
using Cyclops.CloudStorage;
// 删除远程文件
bool success = await client.DeleteAsync("remote-file.jpg");
if (success)
{
Console.WriteLine("文件删除成功");
}
else
{
Console.WriteLine("文件删除失败");
}
using Cyclops.CloudStorage;
// 生成24小时内有效的SAS访问链接
var sasUri = await client.GetSasUri("remote-file.jpg", DateTimeOffset.UtcNow.AddHours(24));
Console.WriteLine($"临时访问链接: {sasUri}");
// sasUri可用于临时访问文件,无需凭证
using Cyclops.CloudStorage;
// 检查文件是否存在
bool exists = await client.ExistAsync("remote-file.jpg");
if (exists)
{
Console.WriteLine("文件存在");
}
else
{
Console.WriteLine("文件不存在");
}
using Cyclops.CloudStorage;
var options = new CloudStorageOptions
{
Id = "LTAI5t666666666666666", // AccessKeyId
Key = "66666666666666666666666666666666", // AccessKeySecret
SupplierType = EnumSupplierType.Aliyun,
ContainerName = "my-bucket",
Endpoint = "oss-cn-hangzhou.aliyuncs.com"
};
using Cyclops.CloudStorage;
var options = new CloudStorageOptions
{
Id = "DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=66666666666666666666666666666666==;EndpointSuffix=core.windows.net",
Key = "", // Azure使用连接字符串,Key可为空
SupplierType = EnumSupplierType.Azure,
ContainerName = "my-container",
Endpoint = "https://myaccount.blob.core.windows.net"
};
using Cyclops.CloudStorage;
var options = new CloudStorageOptions
{
Id = "minioadmin", // AccessKey
Key = "minioadmin", // SecretKey
SupplierType = EnumSupplierType.MinIO,
ContainerName = "my-bucket",
Endpoint = "http://localhost:9000"
};
缓存配置:根据需要启用上传/下载缓存,提高性能
options.EnableDownloadCache = true;
options.EnableUploadCache = true;
超时设置:对于大文件传输,适当调整超时时间
options.TimeOut = 300; // 5分钟
错误重试:设置合适的重试次数,提高稳定性
options.MaxErrorRetry = 5;
文件大小处理:大文件优先使用流操作,小文件可以使用字节数组
我们欢迎社区贡献!如果您有任何想法或建议,欢迎提交 Issue 或 Pull Request。
MIT License
Cyclops.CloudStorage - 让云存储访问变得简单统一,为您的应用提供可靠的存储解决方案!✨
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on TJC.Cyclops.CloudStorage:
| Package | Downloads |
|---|---|
|
TJC.Cyclops.Web.Core
企服版框架中api核心功能项目,基于aspnetcore集成di、jwt、swagger、codefirtst、支持多种常见数据库、nacos配置中心、统一接口回复参数、全局异常捕获、全局接口日志、防重放攻击、图形验证码、快捷上下文对象、上传下载、数据导入导出等功能 |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026.6.11.2 | 137 | 6/11/2026 |
| 2026.6.11.1 | 154 | 6/11/2026 |
| 2026.6.9.4 | 155 | 6/9/2026 |
| 2026.6.9.3 | 168 | 6/9/2026 |
| 2026.6.9.2 | 162 | 6/9/2026 |
| 2026.6.9.1 | 174 | 6/9/2026 |
| 2026.6.8.3 | 180 | 6/8/2026 |
| 2026.6.8.2 | 138 | 6/8/2026 |
| 2026.6.8.1 | 151 | 6/8/2026 |
| 2026.6.5.1 | 150 | 6/5/2026 |
| 2026.5.18.1 | 157 | 5/18/2026 |
| 2026.5.11.1 | 157 | 5/11/2026 |
| 2026.5.7.2 | 148 | 5/7/2026 |
| 2026.5.7.1 | 141 | 5/7/2026 |
| 2026.4.29.2 | 147 | 4/29/2026 |
| 2026.4.29.1 | 160 | 4/29/2026 |
| 2026.4.27.1 | 149 | 4/27/2026 |
| 2026.4.24.2 | 133 | 4/24/2026 |
| 2026.4.24.1 | 139 | 4/24/2026 |
| 2026.4.14.2 | 142 | 4/14/2026 |
企服版框架中云存储SDK,目前支持阿里云、微软Azure、MiniIO的无缝集成