28 changed files with 3414 additions and 48 deletions
@ -0,0 +1,6 @@ |
|||
namespace LINGYUN.Abp.OssManagement.Integration; |
|||
|
|||
public class GetOssObjectExistsResult |
|||
{ |
|||
public bool IsExists { get; set; } |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Content; |
|||
|
|||
namespace LINGYUN.Abp.OssManagement.Integration; |
|||
|
|||
[IntegrationService] |
|||
public interface IOssObjectIntegrationService : IApplicationService |
|||
{ |
|||
Task<OssObjectDto> CreateAsync(CreateOssObjectInput input); |
|||
|
|||
Task DeleteAsync(GetOssObjectInput input); |
|||
|
|||
Task<GetOssObjectExistsResult> ExistsAsync(GetOssObjectInput input); |
|||
|
|||
Task<IRemoteStreamContent> GetAsync(GetOssObjectInput input); |
|||
} |
|||
@ -0,0 +1,94 @@ |
|||
using System; |
|||
using System.IO; |
|||
using System.Threading.Tasks; |
|||
using System.Web; |
|||
using Volo.Abp.Content; |
|||
|
|||
namespace LINGYUN.Abp.OssManagement.Integration; |
|||
|
|||
public class OssObjectIntegrationService : OssManagementApplicationServiceBase, IOssObjectIntegrationService |
|||
{ |
|||
protected FileUploadMerger Merger { get; } |
|||
protected IOssContainerFactory OssContainerFactory { get; } |
|||
|
|||
public OssObjectIntegrationService( |
|||
FileUploadMerger merger, |
|||
IOssContainerFactory ossContainerFactory) |
|||
{ |
|||
Merger = merger; |
|||
OssContainerFactory = ossContainerFactory; |
|||
} |
|||
|
|||
public async virtual Task<OssObjectDto> CreateAsync(CreateOssObjectInput input) |
|||
{ |
|||
// 内容为空时建立目录
|
|||
if (input.File == null || !input.File.ContentLength.HasValue) |
|||
{ |
|||
var oss = CreateOssContainer(); |
|||
var request = new CreateOssObjectRequest( |
|||
HttpUtility.UrlDecode(input.Bucket), |
|||
HttpUtility.UrlDecode(input.FileName), |
|||
Stream.Null, |
|||
HttpUtility.UrlDecode(input.Path)); |
|||
var ossObject = await oss.CreateObjectAsync(request); |
|||
|
|||
return ObjectMapper.Map<OssObject, OssObjectDto>(ossObject); |
|||
} |
|||
else |
|||
{ |
|||
var ossObject = await Merger.MergeAsync(input); |
|||
|
|||
return ObjectMapper.Map<OssObject, OssObjectDto>(ossObject); |
|||
} |
|||
} |
|||
|
|||
public async virtual Task DeleteAsync(GetOssObjectInput input) |
|||
{ |
|||
var oss = CreateOssContainer(); |
|||
|
|||
await oss.DeleteObjectAsync(input.Bucket, input.Object, input.Path); |
|||
} |
|||
|
|||
public async virtual Task<GetOssObjectExistsResult> ExistsAsync(GetOssObjectInput input) |
|||
{ |
|||
try |
|||
{ |
|||
var oss = CreateOssContainer(); |
|||
|
|||
var ossObject = await oss.GetObjectAsync(input.Bucket, input.Object, input.Path, input.MD5); |
|||
|
|||
return new GetOssObjectExistsResult |
|||
{ |
|||
IsExists = ossObject != null |
|||
}; |
|||
} |
|||
catch (Exception) |
|||
{ |
|||
return new GetOssObjectExistsResult |
|||
{ |
|||
IsExists = false, |
|||
}; |
|||
} |
|||
} |
|||
|
|||
public async virtual Task<IRemoteStreamContent> GetAsync(GetOssObjectInput input) |
|||
{ |
|||
try |
|||
{ |
|||
var oss = CreateOssContainer(); |
|||
|
|||
var ossObject = await oss.GetObjectAsync(input.Bucket, input.Object, input.Path, input.MD5); |
|||
|
|||
return new RemoteStreamContent(ossObject.Content, ossObject.Name); |
|||
} |
|||
catch (Exception) |
|||
{ |
|||
return new RemoteStreamContent(Stream.Null); |
|||
} |
|||
} |
|||
|
|||
protected virtual IOssContainer CreateOssContainer() |
|||
{ |
|||
return OssContainerFactory.Create(); |
|||
} |
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.OssManagement; |
|||
using LINGYUN.Abp.OssManagement.Integration; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Content; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Http.Client; |
|||
using Volo.Abp.Http.Client.ClientProxying; |
|||
using Volo.Abp.Http.Modeling; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.OssManagement.Integration; |
|||
|
|||
[Dependency(ReplaceServices = true)] |
|||
[ExposeServices(typeof(IOssObjectIntegrationService), typeof(OssObjectIntegrationClientProxy))] |
|||
[IntegrationService] |
|||
public partial class OssObjectIntegrationClientProxy : ClientProxyBase<IOssObjectIntegrationService>, IOssObjectIntegrationService |
|||
{ |
|||
public virtual async Task<OssObjectDto> CreateAsync(CreateOssObjectInput input) |
|||
{ |
|||
return await RequestAsync<OssObjectDto>(nameof(CreateAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(CreateOssObjectInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task DeleteAsync(GetOssObjectInput input) |
|||
{ |
|||
await RequestAsync(nameof(DeleteAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(GetOssObjectInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<GetOssObjectExistsResult> ExistsAsync(GetOssObjectInput input) |
|||
{ |
|||
return await RequestAsync<GetOssObjectExistsResult>(nameof(ExistsAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(GetOssObjectInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<IRemoteStreamContent> GetAsync(GetOssObjectInput input) |
|||
{ |
|||
return await RequestAsync<IRemoteStreamContent>(nameof(GetAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(GetOssObjectInput), input } |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
// This file is part of OssObjectIntegrationClientProxy, you can customize it here
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.OssManagement.Integration; |
|||
|
|||
public partial class OssObjectIntegrationClientProxy |
|||
{ |
|||
} |
|||
@ -0,0 +1,59 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.OssManagement; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Http.Client; |
|||
using Volo.Abp.Http.Client.ClientProxying; |
|||
using Volo.Abp.Http.Modeling; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.OssManagement; |
|||
|
|||
[Dependency(ReplaceServices = true)] |
|||
[ExposeServices(typeof(IOssContainerAppService), typeof(OssContainerClientProxy))] |
|||
public partial class OssContainerClientProxy : ClientProxyBase<IOssContainerAppService>, IOssContainerAppService |
|||
{ |
|||
public virtual async Task<OssContainerDto> CreateAsync(string name) |
|||
{ |
|||
return await RequestAsync<OssContainerDto>(nameof(CreateAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(string), name } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task DeleteAsync(string name) |
|||
{ |
|||
await RequestAsync(nameof(DeleteAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(string), name } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<OssContainerDto> GetAsync(string name) |
|||
{ |
|||
return await RequestAsync<OssContainerDto>(nameof(GetAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(string), name } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<OssContainersResultDto> GetListAsync(GetOssContainersInput input) |
|||
{ |
|||
return await RequestAsync<OssContainersResultDto>(nameof(GetListAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(GetOssContainersInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<OssObjectsResultDto> GetObjectListAsync(GetOssObjectsInput input) |
|||
{ |
|||
return await RequestAsync<OssObjectsResultDto>(nameof(GetObjectListAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(GetOssObjectsInput), input } |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
// This file is part of OssContainerClientProxy, you can customize it here
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.OssManagement; |
|||
|
|||
public partial class OssContainerClientProxy |
|||
{ |
|||
} |
|||
@ -0,0 +1,60 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.OssManagement; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Content; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Http.Client; |
|||
using Volo.Abp.Http.Client.ClientProxying; |
|||
using Volo.Abp.Http.Modeling; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.OssManagement; |
|||
|
|||
[Dependency(ReplaceServices = true)] |
|||
[ExposeServices(typeof(IOssObjectAppService), typeof(OssObjectClientProxy))] |
|||
public partial class OssObjectClientProxy : ClientProxyBase<IOssObjectAppService>, IOssObjectAppService |
|||
{ |
|||
public virtual async Task<OssObjectDto> CreateAsync(CreateOssObjectInput input) |
|||
{ |
|||
return await RequestAsync<OssObjectDto>(nameof(CreateAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(CreateOssObjectInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task BulkDeleteAsync(BulkDeleteOssObjectInput input) |
|||
{ |
|||
await RequestAsync(nameof(BulkDeleteAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(BulkDeleteOssObjectInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task DeleteAsync(GetOssObjectInput input) |
|||
{ |
|||
await RequestAsync(nameof(DeleteAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(GetOssObjectInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<OssObjectDto> GetAsync(GetOssObjectInput input) |
|||
{ |
|||
return await RequestAsync<OssObjectDto>(nameof(GetAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(GetOssObjectInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<IRemoteStreamContent> GetContentAsync(GetOssObjectInput input) |
|||
{ |
|||
return await RequestAsync<IRemoteStreamContent>(nameof(GetContentAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(GetOssObjectInput), input } |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
// This file is part of OssObjectClientProxy, you can customize it here
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.OssManagement; |
|||
|
|||
public partial class OssObjectClientProxy |
|||
{ |
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.OssManagement; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Content; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Http.Client; |
|||
using Volo.Abp.Http.Client.ClientProxying; |
|||
using Volo.Abp.Http.Modeling; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.OssManagement; |
|||
|
|||
[Dependency(ReplaceServices = true)] |
|||
[ExposeServices(typeof(IFileAppService), typeof(PrivateFilesClientProxy))] |
|||
public partial class PrivateFilesClientProxy : ClientProxyBase<IFileAppService>, IFileAppService |
|||
{ |
|||
public virtual async Task<OssObjectDto> UploadAsync(UploadFileInput input) |
|||
{ |
|||
return await RequestAsync<OssObjectDto>(nameof(UploadAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(UploadFileInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task UploadChunkAsync(UploadFileChunkInput input) |
|||
{ |
|||
await RequestAsync(nameof(UploadChunkAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(UploadFileChunkInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<ListResultDto<OssObjectDto>> GetListAsync(GetFilesInput input) |
|||
{ |
|||
return await RequestAsync<ListResultDto<OssObjectDto>>(nameof(GetListAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(GetFilesInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<IRemoteStreamContent> GetAsync(GetPublicFileInput input) |
|||
{ |
|||
return await RequestAsync<IRemoteStreamContent>(nameof(GetAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(GetPublicFileInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task DeleteAsync(GetPublicFileInput input) |
|||
{ |
|||
await RequestAsync(nameof(DeleteAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(GetPublicFileInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<ListResultDto<MyFileShareDto>> GetShareListAsync() |
|||
{ |
|||
return await RequestAsync<ListResultDto<MyFileShareDto>>(nameof(GetShareListAsync)); |
|||
} |
|||
|
|||
public virtual async Task<FileShareDto> ShareAsync(FileShareInput input) |
|||
{ |
|||
return await RequestAsync<FileShareDto>(nameof(ShareAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(FileShareInput), input } |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
// This file is part of PrivateFilesClientProxy, you can customize it here
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.OssManagement; |
|||
|
|||
public partial class PrivateFilesClientProxy |
|||
{ |
|||
} |
|||
@ -0,0 +1,60 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.OssManagement; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Content; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Http.Client; |
|||
using Volo.Abp.Http.Client.ClientProxying; |
|||
using Volo.Abp.Http.Modeling; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.OssManagement; |
|||
|
|||
[Dependency(ReplaceServices = true)] |
|||
[ExposeServices(typeof(IFileAppService), typeof(PublicFilesClientProxy))] |
|||
public partial class PublicFilesClientProxy : ClientProxyBase<IFileAppService>, IFileAppService |
|||
{ |
|||
public virtual async Task<OssObjectDto> UploadAsync(UploadFileInput input) |
|||
{ |
|||
return await RequestAsync<OssObjectDto>(nameof(UploadAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(UploadFileInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task UploadChunkAsync(UploadFileChunkInput input) |
|||
{ |
|||
await RequestAsync(nameof(UploadChunkAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(UploadFileChunkInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<ListResultDto<OssObjectDto>> GetListAsync(GetFilesInput input) |
|||
{ |
|||
return await RequestAsync<ListResultDto<OssObjectDto>>(nameof(GetListAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(GetFilesInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<IRemoteStreamContent> GetAsync(GetPublicFileInput input) |
|||
{ |
|||
return await RequestAsync<IRemoteStreamContent>(nameof(GetAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(GetPublicFileInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task DeleteAsync(GetPublicFileInput input) |
|||
{ |
|||
await RequestAsync(nameof(DeleteAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(GetPublicFileInput), input } |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
// This file is part of PublicFilesClientProxy, you can customize it here
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.OssManagement; |
|||
|
|||
public partial class PublicFilesClientProxy |
|||
{ |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.OssManagement; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Content; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Http.Client; |
|||
using Volo.Abp.Http.Client.ClientProxying; |
|||
using Volo.Abp.Http.Modeling; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.OssManagement; |
|||
|
|||
[Dependency(ReplaceServices = true)] |
|||
[ExposeServices(typeof(IStaticFilesAppService), typeof(StaticFilesClientProxy))] |
|||
public partial class StaticFilesClientProxy : ClientProxyBase<IStaticFilesAppService>, IStaticFilesAppService |
|||
{ |
|||
public virtual async Task<IRemoteStreamContent> GetAsync(GetStaticFileInput input) |
|||
{ |
|||
return await RequestAsync<IRemoteStreamContent>(nameof(GetAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(GetStaticFileInput), input } |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
// This file is part of StaticFilesClientProxy, you can customize it here
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.OssManagement; |
|||
|
|||
public partial class StaticFilesClientProxy |
|||
{ |
|||
} |
|||
File diff suppressed because it is too large
@ -0,0 +1,47 @@ |
|||
using Asp.Versioning; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Volo.Abp.Content; |
|||
|
|||
namespace LINGYUN.Abp.OssManagement.Integration; |
|||
|
|||
[Area(OssManagementRemoteServiceConsts.ModuleName)] |
|||
[ControllerName("OssObjectIntegration")] |
|||
[RemoteService(Name = OssManagementRemoteServiceConsts.RemoteServiceName)] |
|||
[Route($"integration-api/{OssManagementRemoteServiceConsts.ModuleName}/objects")] |
|||
public class OssObjectIntegrationController : AbpControllerBase, IOssObjectIntegrationService |
|||
{ |
|||
private readonly IOssObjectIntegrationService _service; |
|||
public OssObjectIntegrationController(IOssObjectIntegrationService service) |
|||
{ |
|||
_service = service; |
|||
} |
|||
|
|||
[HttpPost] |
|||
public virtual Task<OssObjectDto> CreateAsync([FromForm] CreateOssObjectInput input) |
|||
{ |
|||
return _service.CreateAsync(input); |
|||
} |
|||
|
|||
[HttpDelete] |
|||
public virtual Task DeleteAsync(GetOssObjectInput input) |
|||
{ |
|||
return _service.DeleteAsync(input); |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("exists")] |
|||
public virtual Task<GetOssObjectExistsResult> ExistsAsync(GetOssObjectInput input) |
|||
{ |
|||
return _service.ExistsAsync(input); |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("download")] |
|||
public virtual Task<IRemoteStreamContent> GetAsync(GetOssObjectInput input) |
|||
{ |
|||
return _service.GetAsync(input); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue