4 changed files with 430 additions and 0 deletions
@ -0,0 +1,95 @@ |
|||||
|
# LINGYUN.Abp.BlobStoring.Nexus |
||||
|
|
||||
|
[简体中文](./README.md) | English |
||||
|
|
||||
|
A BLOB storage provider based on Sonatype Nexus. |
||||
|
|
||||
|
## Features |
||||
|
|
||||
|
* Support for storing files in Nexus repository |
||||
|
* Support for basic file operations including upload, download, and delete |
||||
|
* Support for file path normalization |
||||
|
* Support for file duplication check and override options |
||||
|
* Multi-tenancy support |
||||
|
|
||||
|
## Module Dependencies |
||||
|
|
||||
|
```csharp |
||||
|
[DependsOn(typeof(AbpBlobStoringNexusModule))] |
||||
|
public class YouProjectModule : AbpModule |
||||
|
{ |
||||
|
// other |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## Basic Usage |
||||
|
|
||||
|
### 1. Configure Nexus Storage |
||||
|
|
||||
|
Configure Nexus storage options in `appsettings.json`: |
||||
|
|
||||
|
```json |
||||
|
{ |
||||
|
"BlobStoring": { |
||||
|
"Nexus": { |
||||
|
"Repository": "your-repository-name" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### 2. Configure Container |
||||
|
|
||||
|
```csharp |
||||
|
Configure<AbpBlobStoringOptions>(options => |
||||
|
{ |
||||
|
options.Containers.ConfigureDefault(container => |
||||
|
{ |
||||
|
container.UseNexus(nexus => |
||||
|
{ |
||||
|
nexus.Repository = "your-repository-name"; |
||||
|
}); |
||||
|
}); |
||||
|
}); |
||||
|
``` |
||||
|
|
||||
|
### 3. Use BLOB Storage |
||||
|
|
||||
|
```csharp |
||||
|
public class MyService |
||||
|
{ |
||||
|
private readonly IBlobContainer _blobContainer; |
||||
|
|
||||
|
public MyService(IBlobContainer blobContainer) |
||||
|
{ |
||||
|
_blobContainer = blobContainer; |
||||
|
} |
||||
|
|
||||
|
public async Task SaveBlobAsync(byte[] bytes) |
||||
|
{ |
||||
|
await _blobContainer.SaveAsync("my-blob-name", bytes); |
||||
|
} |
||||
|
|
||||
|
public async Task<byte[]> GetBlobAsync() |
||||
|
{ |
||||
|
return await _blobContainer.GetAllBytesAsync("my-blob-name"); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## Configuration Options |
||||
|
|
||||
|
* Repository - Nexus repository name |
||||
|
|
||||
|
## Best Practices |
||||
|
|
||||
|
1. Plan file paths and naming properly for better management and maintenance |
||||
|
2. Configure file override options based on actual requirements |
||||
|
3. Use multi-tenancy features appropriately to ensure data isolation |
||||
|
|
||||
|
## Notes |
||||
|
|
||||
|
1. Ensure Nexus repository is properly configured and accessible |
||||
|
2. File paths are automatically normalized, replacing backslashes with forward slashes |
||||
|
3. By default, overwriting existing files is not allowed, the OverrideExisting option needs to be explicitly set |
||||
|
4. File operations may be affected by network conditions, consider adding appropriate error handling mechanisms |
||||
@ -0,0 +1,95 @@ |
|||||
|
# LINGYUN.Abp.BlobStoring.Nexus |
||||
|
|
||||
|
[English](./README.EN.md) | 简体中文 |
||||
|
|
||||
|
基于 Sonatype Nexus 的 Blob 存储提供程序。 |
||||
|
|
||||
|
## 功能 |
||||
|
|
||||
|
* 支持将文件存储到 Nexus 仓库 |
||||
|
* 支持文件的上传、下载、删除等基本操作 |
||||
|
* 支持文件路径规范化 |
||||
|
* 支持文件重复检查和覆盖选项 |
||||
|
* 支持多租户 |
||||
|
|
||||
|
## 模块依赖 |
||||
|
|
||||
|
```csharp |
||||
|
[DependsOn(typeof(AbpBlobStoringNexusModule))] |
||||
|
public class YouProjectModule : AbpModule |
||||
|
{ |
||||
|
// other |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## 基本用法 |
||||
|
|
||||
|
### 1. 配置 Nexus 存储 |
||||
|
|
||||
|
在 `appsettings.json` 中配置 Nexus 存储选项: |
||||
|
|
||||
|
```json |
||||
|
{ |
||||
|
"BlobStoring": { |
||||
|
"Nexus": { |
||||
|
"Repository": "your-repository-name" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### 2. 配置容器 |
||||
|
|
||||
|
```csharp |
||||
|
Configure<AbpBlobStoringOptions>(options => |
||||
|
{ |
||||
|
options.Containers.ConfigureDefault(container => |
||||
|
{ |
||||
|
container.UseNexus(nexus => |
||||
|
{ |
||||
|
nexus.Repository = "your-repository-name"; |
||||
|
}); |
||||
|
}); |
||||
|
}); |
||||
|
``` |
||||
|
|
||||
|
### 3. 使用 BLOB 存储 |
||||
|
|
||||
|
```csharp |
||||
|
public class MyService |
||||
|
{ |
||||
|
private readonly IBlobContainer _blobContainer; |
||||
|
|
||||
|
public MyService(IBlobContainer blobContainer) |
||||
|
{ |
||||
|
_blobContainer = blobContainer; |
||||
|
} |
||||
|
|
||||
|
public async Task SaveBlobAsync(byte[] bytes) |
||||
|
{ |
||||
|
await _blobContainer.SaveAsync("my-blob-name", bytes); |
||||
|
} |
||||
|
|
||||
|
public async Task<byte[]> GetBlobAsync() |
||||
|
{ |
||||
|
return await _blobContainer.GetAllBytesAsync("my-blob-name"); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## 配置选项 |
||||
|
|
||||
|
* Repository - Nexus 仓库名称 |
||||
|
|
||||
|
## 最佳实践 |
||||
|
|
||||
|
1. 合理规划文件路径和命名,便于管理和维护 |
||||
|
2. 根据实际需求配置文件覆盖选项 |
||||
|
3. 合理使用多租户功能,确保数据隔离 |
||||
|
|
||||
|
## 注意事项 |
||||
|
|
||||
|
1. 确保 Nexus 仓库已正确配置并可访问 |
||||
|
2. 文件路径会被自动规范化,将反斜杠替换为正斜杠 |
||||
|
3. 默认情况下不允许覆盖已存在的文件,需要显式设置 OverrideExisting 选项 |
||||
|
4. 文件操作可能会受到网络状况的影响,建议添加适当的错误处理机制 |
||||
@ -0,0 +1,120 @@ |
|||||
|
# LINGYUN.Abp.Sonatype.Nexus |
||||
|
|
||||
|
[简体中文](./README.md) | English |
||||
|
|
||||
|
ABP framework integration module for Sonatype Nexus REST API. |
||||
|
|
||||
|
## Features |
||||
|
|
||||
|
* Support for Nexus repository management |
||||
|
* Support for component management |
||||
|
* Support for asset management |
||||
|
* Support for search functionality |
||||
|
* Support for basic authentication |
||||
|
|
||||
|
## Module Dependencies |
||||
|
|
||||
|
```csharp |
||||
|
[DependsOn(typeof(AbpSonatypeNexusModule))] |
||||
|
public class YouProjectModule : AbpModule |
||||
|
{ |
||||
|
// other |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## Basic Usage |
||||
|
|
||||
|
### 1. Configure Nexus Connection |
||||
|
|
||||
|
Configure Nexus connection options in `appsettings.json`: |
||||
|
|
||||
|
```json |
||||
|
{ |
||||
|
"SonatypeNexus": { |
||||
|
"BaseUrl": "http://127.0.0.1:8081", |
||||
|
"UserName": "sonatype", |
||||
|
"Password": "sonatype" |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### 2. Use Repository Management |
||||
|
|
||||
|
```csharp |
||||
|
public class MyService |
||||
|
{ |
||||
|
private readonly INexusRepositoryManager _repositoryManager; |
||||
|
|
||||
|
public MyService(INexusRepositoryManager repositoryManager) |
||||
|
{ |
||||
|
_repositoryManager = repositoryManager; |
||||
|
} |
||||
|
|
||||
|
public async Task<List<NexusRepository>> GetRepositoriesAsync() |
||||
|
{ |
||||
|
var result = await _repositoryManager.ListAsync(); |
||||
|
return result.Items; |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### 3. Use Component Management |
||||
|
|
||||
|
```csharp |
||||
|
public class MyService |
||||
|
{ |
||||
|
private readonly INexusComponentManager _componentManager; |
||||
|
|
||||
|
public MyService(INexusComponentManager componentManager) |
||||
|
{ |
||||
|
_componentManager = componentManager; |
||||
|
} |
||||
|
|
||||
|
public async Task UploadComponentAsync(string repository, string directory, byte[] fileBytes) |
||||
|
{ |
||||
|
var asset = new Asset("filename.txt", fileBytes); |
||||
|
var args = new NexusRawBlobUploadArgs(repository, directory, asset); |
||||
|
await _componentManager.UploadAsync(args); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### 4. Use Asset Management |
||||
|
|
||||
|
```csharp |
||||
|
public class MyService |
||||
|
{ |
||||
|
private readonly INexusAssetManager _assetManager; |
||||
|
|
||||
|
public MyService(INexusAssetManager assetManager) |
||||
|
{ |
||||
|
_assetManager = assetManager; |
||||
|
} |
||||
|
|
||||
|
public async Task<List<NexusAsset>> GetAssetsAsync(string repository) |
||||
|
{ |
||||
|
var result = await _assetManager.ListAsync(repository); |
||||
|
return result.Items; |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## Configuration Options |
||||
|
|
||||
|
* BaseUrl - Nexus server address |
||||
|
* UserName - Username |
||||
|
* Password - Password |
||||
|
|
||||
|
## Best Practices |
||||
|
|
||||
|
1. Keep authentication information secure |
||||
|
2. Plan repository structure and component classification properly |
||||
|
3. Regularly clean up unnecessary components and assets |
||||
|
4. Use appropriate error handling mechanisms |
||||
|
|
||||
|
## Notes |
||||
|
|
||||
|
1. Ensure Nexus server is properly configured and accessible |
||||
|
2. Consider network conditions and timeout settings when uploading large files |
||||
|
3. Delete operations are irreversible, proceed with caution |
||||
|
4. Some operations require administrator privileges |
||||
@ -0,0 +1,120 @@ |
|||||
|
# LINGYUN.Abp.Sonatype.Nexus |
||||
|
|
||||
|
[English](./README.EN.md) | 简体中文 |
||||
|
|
||||
|
Sonatype Nexus REST API 的 ABP 框架集成模块。 |
||||
|
|
||||
|
## 功能 |
||||
|
|
||||
|
* 支持 Nexus 仓库管理 |
||||
|
* 支持组件(Component)管理 |
||||
|
* 支持资源(Asset)管理 |
||||
|
* 支持搜索功能 |
||||
|
* 支持基本认证 |
||||
|
|
||||
|
## 模块依赖 |
||||
|
|
||||
|
```csharp |
||||
|
[DependsOn(typeof(AbpSonatypeNexusModule))] |
||||
|
public class YouProjectModule : AbpModule |
||||
|
{ |
||||
|
// other |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## 基本用法 |
||||
|
|
||||
|
### 1. 配置 Nexus 连接 |
||||
|
|
||||
|
在 `appsettings.json` 中配置 Nexus 连接选项: |
||||
|
|
||||
|
```json |
||||
|
{ |
||||
|
"SonatypeNexus": { |
||||
|
"BaseUrl": "http://127.0.0.1:8081", |
||||
|
"UserName": "sonatype", |
||||
|
"Password": "sonatype" |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### 2. 使用仓库管理 |
||||
|
|
||||
|
```csharp |
||||
|
public class MyService |
||||
|
{ |
||||
|
private readonly INexusRepositoryManager _repositoryManager; |
||||
|
|
||||
|
public MyService(INexusRepositoryManager repositoryManager) |
||||
|
{ |
||||
|
_repositoryManager = repositoryManager; |
||||
|
} |
||||
|
|
||||
|
public async Task<List<NexusRepository>> GetRepositoriesAsync() |
||||
|
{ |
||||
|
var result = await _repositoryManager.ListAsync(); |
||||
|
return result.Items; |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### 3. 使用组件管理 |
||||
|
|
||||
|
```csharp |
||||
|
public class MyService |
||||
|
{ |
||||
|
private readonly INexusComponentManager _componentManager; |
||||
|
|
||||
|
public MyService(INexusComponentManager componentManager) |
||||
|
{ |
||||
|
_componentManager = componentManager; |
||||
|
} |
||||
|
|
||||
|
public async Task UploadComponentAsync(string repository, string directory, byte[] fileBytes) |
||||
|
{ |
||||
|
var asset = new Asset("filename.txt", fileBytes); |
||||
|
var args = new NexusRawBlobUploadArgs(repository, directory, asset); |
||||
|
await _componentManager.UploadAsync(args); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
### 4. 使用资源管理 |
||||
|
|
||||
|
```csharp |
||||
|
public class MyService |
||||
|
{ |
||||
|
private readonly INexusAssetManager _assetManager; |
||||
|
|
||||
|
public MyService(INexusAssetManager assetManager) |
||||
|
{ |
||||
|
_assetManager = assetManager; |
||||
|
} |
||||
|
|
||||
|
public async Task<List<NexusAsset>> GetAssetsAsync(string repository) |
||||
|
{ |
||||
|
var result = await _assetManager.ListAsync(repository); |
||||
|
return result.Items; |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
## 配置选项 |
||||
|
|
||||
|
* BaseUrl - Nexus 服务器地址 |
||||
|
* UserName - 用户名 |
||||
|
* Password - 密码 |
||||
|
|
||||
|
## 最佳实践 |
||||
|
|
||||
|
1. 妥善保管认证信息,避免泄露 |
||||
|
2. 合理规划仓库结构和组件分类 |
||||
|
3. 定期清理不需要的组件和资源 |
||||
|
4. 使用适当的错误处理机制 |
||||
|
|
||||
|
## 注意事项 |
||||
|
|
||||
|
1. 确保 Nexus 服务器已正确配置并可访问 |
||||
|
2. 上传大文件时需要注意网络状况和超时设置 |
||||
|
3. 删除操作不可恢复,请谨慎操作 |
||||
|
4. 部分操作需要管理员权限 |
||||
Loading…
Reference in new issue