Browse Source
Migrate the local file system blobs written by the legacy OssManagement to BlobManagement, so an existing deployment can be moved to the new storage without touching the files by hand. - add BlobMigrationCommand (blob-migration): walk the working directory and upload every file matching the search pattern through IBlobIntegrationService; the options cover the working directory (-wd), the search option (-so) and pattern (-sp), the bucket (-bn), the blob path (-pn) and name (-on), the service url (-u), the tenant (-t) and overwrite (-ow), plus a list only mode (-ls) to confirm the blob names first - add ICurrentBlob/CurrentBlob and BlobHttpClientHandler so the command can retarget the client proxies to the given BlobManagement url, send the __tenant header and skip the result wrapper for the current run - register the BlobManagement static client proxies and AbpHttpClientModule in AbpCliModule, and embed the generated ClientProxies json into the assembly - add the Volo.Abp.Ddd.Application.Contracts and Volo.Abp.Http.Client references, and make CreateCommand.GetUsageInfo virtual so the new command can reuse it - set an output template for the file logger and split the launchSettings profiles into one profile per commandpull/1611/head
46 changed files with 41390 additions and 8 deletions
@ -0,0 +1,109 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement; |
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
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.BlobManagement; |
|||
|
|||
[Dependency(ReplaceServices = true)] |
|||
[ExposeServices(typeof(IBlobAppService), typeof(BlobClientProxy))] |
|||
public partial class BlobClientProxy : ClientProxyBase<IBlobAppService>, IBlobAppService |
|||
{ |
|||
public virtual async Task<BlobDto> CreateFileAsync(BlobFileCreateDto input) |
|||
{ |
|||
return await RequestAsync<BlobDto>(nameof(CreateFileAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(BlobFileCreateDto), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task CreateChunkFileAsync(BlobFileChunkCreateDto input) |
|||
{ |
|||
await RequestAsync(nameof(CreateChunkFileAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(BlobFileChunkCreateDto), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<BlobDto> CreateFolderAsync(BlobFolderCreateDto input) |
|||
{ |
|||
return await RequestAsync<BlobDto>(nameof(CreateFolderAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(BlobFolderCreateDto), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task DeleteAsync(Guid id) |
|||
{ |
|||
await RequestAsync(nameof(DeleteAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(Guid), id } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<IRemoteStreamContent> DownloadAsync(BlobDownloadByIdInput input) |
|||
{ |
|||
return await RequestAsync<IRemoteStreamContent>(nameof(DownloadAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(BlobDownloadByIdInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<IRemoteStreamContent> PreviewAsync(BlobDownloadByIdInput input) |
|||
{ |
|||
return await RequestAsync<IRemoteStreamContent>(nameof(PreviewAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(BlobDownloadByIdInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<IRemoteStreamContent> DownloadByNameAsync(BlobDownloadByNameInput input) |
|||
{ |
|||
return await RequestAsync<IRemoteStreamContent>(nameof(DownloadByNameAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(BlobDownloadByNameInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<BlobDto> GetAsync(Guid id) |
|||
{ |
|||
return await RequestAsync<BlobDto>(nameof(GetAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(Guid), id } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<PagedResultDto<BlobDto>> GetListAsync(BlobGetPagedListInput input) |
|||
{ |
|||
return await RequestAsync<PagedResultDto<BlobDto>>(nameof(GetListAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(BlobGetPagedListInput), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<string> GenerateDownloadUrlAsync(Guid id) |
|||
{ |
|||
return await RequestAsync<string>(nameof(GenerateDownloadUrlAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(Guid), id } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<string> GeneratePreviewUrlAsync(Guid id) |
|||
{ |
|||
return await RequestAsync<string>(nameof(GeneratePreviewUrlAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(Guid), id } |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
// This file is part of BlobClientProxy, you can customize it here
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement; |
|||
|
|||
public partial class BlobClientProxy |
|||
{ |
|||
} |
|||
@ -0,0 +1,52 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement; |
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
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.BlobManagement; |
|||
|
|||
[Dependency(ReplaceServices = true)] |
|||
[ExposeServices(typeof(IBlobContainerAppService), typeof(BlobContainerClientProxy))] |
|||
public partial class BlobContainerClientProxy : ClientProxyBase<IBlobContainerAppService>, IBlobContainerAppService |
|||
{ |
|||
public virtual async Task<BlobContainerDto> CreateAsync(BlobContainerCreateDto input) |
|||
{ |
|||
return await RequestAsync<BlobContainerDto>(nameof(CreateAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(BlobContainerCreateDto), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task DeleteAsync(Guid id) |
|||
{ |
|||
await RequestAsync(nameof(DeleteAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(Guid), id } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<BlobContainerDto> GetAsync(Guid id) |
|||
{ |
|||
return await RequestAsync<BlobContainerDto>(nameof(GetAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(Guid), id } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<PagedResultDto<BlobContainerDto>> GetListAsync(BlobContainerGetPagedListInput input) |
|||
{ |
|||
return await RequestAsync<PagedResultDto<BlobContainerDto>>(nameof(GetListAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(BlobContainerGetPagedListInput), input } |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
// This file is part of BlobContainerClientProxy, you can customize it here
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement; |
|||
|
|||
public partial class BlobContainerClientProxy |
|||
{ |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement; |
|||
|
|||
public enum BlobType |
|||
{ |
|||
Folder = 0, |
|||
File = 1 |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Dtos; |
|||
|
|||
public class BlobContainerCreateDto |
|||
{ |
|||
public string Name { get; set; } |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Dtos; |
|||
|
|||
public class BlobContainerDto : ExtensibleAuditedEntityDto<Guid> |
|||
{ |
|||
public string Name { get; set; } |
|||
|
|||
public string ConcurrencyStamp { get; set; } |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Dtos; |
|||
|
|||
public class BlobContainerGetPagedListInput : PagedAndSortedResultRequestDto |
|||
{ |
|||
public string Filter { get; set; } |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Dtos; |
|||
|
|||
public class BlobDownloadByIdInput |
|||
{ |
|||
public string Key { get; set; } |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Dtos; |
|||
|
|||
public class BlobDownloadByNameInput |
|||
{ |
|||
public Guid? TenantId { get; set; } |
|||
|
|||
public string ContainerName { get; set; } |
|||
|
|||
public string BlobName { get; set; } |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement; |
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Dtos; |
|||
|
|||
public class BlobDto : ExtensibleAuditedEntityDto<Guid> |
|||
{ |
|||
public string Name { get; set; } |
|||
|
|||
public string FullName { get; set; } |
|||
|
|||
public BlobType Type { get; set; } |
|||
|
|||
public string ContentType { get; set; } |
|||
|
|||
public long Size { get; set; } |
|||
|
|||
public DateTime? ExpirationTime { get; set; } |
|||
|
|||
public long DownloadCount { get; set; } |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Dtos; |
|||
|
|||
public class BlobFileChunkCreateBaseDto : BlobFileCreateBaseDto |
|||
{ |
|||
public long ChunkSize { get; set; } |
|||
|
|||
public long CurrentChunkSize { get; set; } |
|||
|
|||
public int ChunkNumber { get; set; } |
|||
|
|||
public int TotalChunks { get; set; } |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Dtos; |
|||
|
|||
public class BlobFileChunkCreateDto : BlobFileChunkCreateBaseDto |
|||
{ |
|||
public Guid ContainerId { get; set; } |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Dtos; |
|||
|
|||
public class BlobFileChunkCreateWithoutContainerDto : BlobFileChunkCreateBaseDto |
|||
{ |
|||
|
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Content; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Dtos; |
|||
|
|||
public class BlobFileCreateBaseDto |
|||
{ |
|||
public string CompareMd5 { get; set; } |
|||
|
|||
public string Name { get; set; } |
|||
|
|||
public Guid? ParentId { get; set; } |
|||
|
|||
public IRemoteStreamContent File { get; set; } |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Dtos; |
|||
|
|||
public class BlobFileCreateDto : BlobFileCreateBaseDto |
|||
{ |
|||
public Guid ContainerId { get; set; } |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Dtos; |
|||
|
|||
public class BlobFileCreateWithoutContainerDto : BlobFileCreateBaseDto |
|||
{ |
|||
|
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Dtos; |
|||
|
|||
public class BlobFolderCreateBaseDto |
|||
{ |
|||
public string Name { get; set; } |
|||
|
|||
public Guid? ParentId { get; set; } |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Dtos; |
|||
|
|||
public class BlobFolderCreateDto : BlobFolderCreateBaseDto |
|||
{ |
|||
public Guid ContainerId { get; set; } |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Dtos; |
|||
|
|||
public class BlobFolderCreateWithoutContainerDto : BlobFolderCreateBaseDto |
|||
{ |
|||
|
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Dtos; |
|||
|
|||
public class BlobGetPagedListInput : BlobGetPagedListInputBase |
|||
{ |
|||
public Guid ContainerId { get; set; } |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement; |
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Dtos; |
|||
|
|||
public class BlobGetPagedListInputBase : PagedAndSortedResultRequestDto |
|||
{ |
|||
public Guid? ParentId { get; set; } |
|||
|
|||
public BlobType? Type { get; set; } |
|||
|
|||
public string ContentType { get; set; } |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Dtos; |
|||
|
|||
public class BlobGetPagedListWithoutContainerInput : BlobGetPagedListInputBase |
|||
{ |
|||
|
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement; |
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Content; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement; |
|||
|
|||
public interface IBlobAppService : IApplicationService |
|||
{ |
|||
Task<BlobDto> CreateFileAsync(BlobFileCreateDto input); |
|||
|
|||
Task CreateChunkFileAsync(BlobFileChunkCreateDto input); |
|||
|
|||
Task<BlobDto> CreateFolderAsync(BlobFolderCreateDto input); |
|||
|
|||
Task DeleteAsync(Guid id); |
|||
|
|||
Task<string> GeneratePreviewUrlAsync(Guid id); |
|||
|
|||
Task<string> GenerateDownloadUrlAsync(Guid id); |
|||
|
|||
Task<IRemoteStreamContent> DownloadAsync(BlobDownloadByIdInput input); |
|||
|
|||
Task<IRemoteStreamContent> PreviewAsync(BlobDownloadByIdInput input); |
|||
|
|||
Task<IRemoteStreamContent> DownloadByNameAsync(BlobDownloadByNameInput input); |
|||
|
|||
Task<BlobDto> GetAsync(Guid id); |
|||
|
|||
Task<PagedResultDto<BlobDto>> GetListAsync(BlobGetPagedListInput input); |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement; |
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement; |
|||
|
|||
public interface IBlobContainerAppService : IApplicationService |
|||
{ |
|||
Task<BlobContainerDto> CreateAsync(BlobContainerCreateDto input); |
|||
|
|||
Task DeleteAsync(Guid id); |
|||
|
|||
Task<BlobContainerDto> GetAsync(Guid id); |
|||
|
|||
Task<PagedResultDto<BlobContainerDto>> GetListAsync(BlobContainerGetPagedListInput input); |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement; |
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Content; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement; |
|||
|
|||
public interface IPrivateBlobAppService : IApplicationService |
|||
{ |
|||
Task<BlobDto> CreateFileAsync(BlobFileCreateWithoutContainerDto input); |
|||
|
|||
Task CreateChunkFileAsync(BlobFileChunkCreateWithoutContainerDto input); |
|||
|
|||
Task<BlobDto> CreateFolderAsync(BlobFolderCreateWithoutContainerDto input); |
|||
|
|||
Task DeleteAsync(Guid id); |
|||
|
|||
Task<IRemoteStreamContent> DownloadAsync(Guid id); |
|||
|
|||
Task<IRemoteStreamContent> DownloadByNameAsync(string name); |
|||
|
|||
Task<BlobDto> GetAsync(Guid id); |
|||
|
|||
Task<PagedResultDto<BlobDto>> GetListAsync(BlobGetPagedListWithoutContainerInput input); |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement; |
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Content; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement; |
|||
|
|||
public interface IPublicBlobAppService : IApplicationService |
|||
{ |
|||
Task<IRemoteStreamContent> DownloadAsync(Guid id); |
|||
|
|||
Task<IRemoteStreamContent> DownloadByNameAsync(string name); |
|||
|
|||
Task<BlobDto> GetAsync(Guid id); |
|||
|
|||
Task<PagedResultDto<BlobDto>> GetListAsync(BlobGetPagedListWithoutContainerInput input); |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using LINGYUN.Abp.BlobManagement.Integration; |
|||
using LINGYUN.Abp.BlobManagement.Integration.Dtos; |
|||
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.BlobManagement.Integration; |
|||
|
|||
[Dependency(ReplaceServices = true)] |
|||
[ExposeServices(typeof(IBlobIntegrationService), typeof(BlobIntegrationClientProxy))] |
|||
[IntegrationService] |
|||
public partial class BlobIntegrationClientProxy : ClientProxyBase<IBlobIntegrationService>, IBlobIntegrationService |
|||
{ |
|||
public virtual async Task<BlobDto> CreateAsync(BlobFileCreateIntegrationDto input) |
|||
{ |
|||
return await RequestAsync<BlobDto>(nameof(CreateAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(BlobFileCreateIntegrationDto), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task DeleteAsync(BlobFileGetByNameIntegrationDto input) |
|||
{ |
|||
await RequestAsync(nameof(DeleteAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(BlobFileGetByNameIntegrationDto), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<bool> ExistsAsync(BlobFileGetByNameIntegrationDto input) |
|||
{ |
|||
return await RequestAsync<bool>(nameof(ExistsAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(BlobFileGetByNameIntegrationDto), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<IRemoteStreamContent> DownloadAsync(BlobFileGetByNameIntegrationDto input) |
|||
{ |
|||
return await RequestAsync<IRemoteStreamContent>(nameof(DownloadAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(BlobFileGetByNameIntegrationDto), input } |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
// This file is part of BlobIntegrationClientProxy, you can customize it here
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Integration; |
|||
|
|||
public partial class BlobIntegrationClientProxy |
|||
{ |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Integration.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Content; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Integration.Dtos; |
|||
|
|||
public class BlobFileCreateIntegrationDto : BlobFileGetByNameIntegrationDto |
|||
{ |
|||
public bool? Overwrite { get; set; } |
|||
|
|||
public IRemoteStreamContent File { get; set; } |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Integration.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Integration.Dtos; |
|||
|
|||
public class BlobFileGetByNameIntegrationDto |
|||
{ |
|||
public string ContainerName { get; set; } |
|||
|
|||
public string BlobName { get; set; } |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
using LINGYUN.Abp.BlobManagement.Integration; |
|||
using LINGYUN.Abp.BlobManagement.Integration.Dtos; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Content; |
|||
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement.Integration; |
|||
|
|||
public interface IBlobIntegrationService : IApplicationService |
|||
{ |
|||
Task<BlobDto> CreateAsync(BlobFileCreateIntegrationDto input); |
|||
|
|||
Task DeleteAsync(BlobFileGetByNameIntegrationDto input); |
|||
|
|||
Task<bool> ExistsAsync(BlobFileGetByNameIntegrationDto input); |
|||
|
|||
Task<IRemoteStreamContent> DownloadAsync(BlobFileGetByNameIntegrationDto input); |
|||
} |
|||
@ -0,0 +1,85 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement; |
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
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.BlobManagement; |
|||
|
|||
[Dependency(ReplaceServices = true)] |
|||
[ExposeServices(typeof(IPrivateBlobAppService), typeof(PrivateBlobClientProxy))] |
|||
public partial class PrivateBlobClientProxy : ClientProxyBase<IPrivateBlobAppService>, IPrivateBlobAppService |
|||
{ |
|||
public virtual async Task<BlobDto> CreateFileAsync(BlobFileCreateWithoutContainerDto input) |
|||
{ |
|||
return await RequestAsync<BlobDto>(nameof(CreateFileAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(BlobFileCreateWithoutContainerDto), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task CreateChunkFileAsync(BlobFileChunkCreateWithoutContainerDto input) |
|||
{ |
|||
await RequestAsync(nameof(CreateChunkFileAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(BlobFileChunkCreateWithoutContainerDto), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<BlobDto> CreateFolderAsync(BlobFolderCreateWithoutContainerDto input) |
|||
{ |
|||
return await RequestAsync<BlobDto>(nameof(CreateFolderAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(BlobFolderCreateWithoutContainerDto), input } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task DeleteAsync(Guid id) |
|||
{ |
|||
await RequestAsync(nameof(DeleteAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(Guid), id } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<IRemoteStreamContent> DownloadAsync(Guid id) |
|||
{ |
|||
return await RequestAsync<IRemoteStreamContent>(nameof(DownloadAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(Guid), id } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<IRemoteStreamContent> DownloadByNameAsync(string name) |
|||
{ |
|||
return await RequestAsync<IRemoteStreamContent>(nameof(DownloadByNameAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(string), name } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<BlobDto> GetAsync(Guid id) |
|||
{ |
|||
return await RequestAsync<BlobDto>(nameof(GetAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(Guid), id } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<PagedResultDto<BlobDto>> GetListAsync(BlobGetPagedListWithoutContainerInput input) |
|||
{ |
|||
return await RequestAsync<PagedResultDto<BlobDto>>(nameof(GetListAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(BlobGetPagedListWithoutContainerInput), input } |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
// This file is part of PrivateBlobClientProxy, you can customize it here
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement; |
|||
|
|||
public partial class PrivateBlobClientProxy |
|||
{ |
|||
} |
|||
@ -0,0 +1,53 @@ |
|||
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
|
|||
using LINGYUN.Abp.BlobManagement; |
|||
using LINGYUN.Abp.BlobManagement.Dtos; |
|||
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.BlobManagement; |
|||
|
|||
[Dependency(ReplaceServices = true)] |
|||
[ExposeServices(typeof(IPublicBlobAppService), typeof(PublicBlobClientProxy))] |
|||
public partial class PublicBlobClientProxy : ClientProxyBase<IPublicBlobAppService>, IPublicBlobAppService |
|||
{ |
|||
public virtual async Task<IRemoteStreamContent> DownloadAsync(Guid id) |
|||
{ |
|||
return await RequestAsync<IRemoteStreamContent>(nameof(DownloadAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(Guid), id } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<IRemoteStreamContent> DownloadByNameAsync(string name) |
|||
{ |
|||
return await RequestAsync<IRemoteStreamContent>(nameof(DownloadByNameAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(string), name } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<BlobDto> GetAsync(Guid id) |
|||
{ |
|||
return await RequestAsync<BlobDto>(nameof(GetAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(Guid), id } |
|||
}); |
|||
} |
|||
|
|||
public virtual async Task<PagedResultDto<BlobDto>> GetListAsync(BlobGetPagedListWithoutContainerInput input) |
|||
{ |
|||
return await RequestAsync<PagedResultDto<BlobDto>>(nameof(GetListAsync), new ClientProxyRequestTypeValue |
|||
{ |
|||
{ typeof(BlobGetPagedListWithoutContainerInput), input } |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
// This file is part of PublicBlobClientProxy, you can customize it here
|
|||
// ReSharper disable once CheckNamespace
|
|||
namespace LINGYUN.Abp.BlobManagement; |
|||
|
|||
public partial class PublicBlobClientProxy |
|||
{ |
|||
} |
|||
File diff suppressed because it is too large
@ -0,0 +1,43 @@ |
|||
using System; |
|||
using System.Net.Http; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.Cli.Blob; |
|||
|
|||
public class BlobHttpClientHandler : DelegatingHandler |
|||
{ |
|||
protected ICurrentBlob CurrentBlob { get; } |
|||
public BlobHttpClientHandler(ICurrentBlob currentBlob) |
|||
{ |
|||
CurrentBlob = currentBlob; |
|||
} |
|||
|
|||
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) |
|||
{ |
|||
if (!CurrentBlob.BaseUrl.IsNullOrWhiteSpace() && request.RequestUri != null) |
|||
{ |
|||
if (request.RequestUri is { } original) |
|||
{ |
|||
var pathAndQuery = original.IsAbsoluteUri |
|||
? original.PathAndQuery |
|||
: original.ToString(); |
|||
|
|||
var builder = new UriBuilder(CurrentBlob.BaseUrl) |
|||
{ |
|||
Path = original.IsAbsoluteUri ? original.AbsolutePath : pathAndQuery.Split('?')[0], |
|||
Query = original.IsAbsoluteUri ? original.Query.TrimStart('?') : "" |
|||
}; |
|||
request.RequestUri = builder.Uri; |
|||
} |
|||
} |
|||
if (!CurrentBlob.TenantId.IsNullOrWhiteSpace()) |
|||
{ |
|||
request.Headers.TryAddWithoutValidation("__tenant", CurrentBlob.TenantId); |
|||
} |
|||
|
|||
request.Headers.TryAddWithoutValidation("_AbpDontWrapResult", bool.TrueString); |
|||
|
|||
return base.SendAsync(request, cancellationToken); |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
namespace LINGYUN.Abp.Cli.Blob; |
|||
|
|||
public class CurrentBlob : ICurrentBlob |
|||
{ |
|||
public string BaseUrl { get; set; } |
|||
|
|||
public string TenantId { get; set; } |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
namespace LINGYUN.Abp.Cli.Blob; |
|||
|
|||
public interface ICurrentBlob |
|||
{ |
|||
string BaseUrl { get; set; } |
|||
|
|||
string TenantId { get; set; } |
|||
} |
|||
@ -0,0 +1,297 @@ |
|||
using LINGYUN.Abp.BlobManagement.Integration; |
|||
using LINGYUN.Abp.Cli.Blob; |
|||
using Microsoft.Extensions.Logging; |
|||
using Microsoft.Extensions.Logging.Abstractions; |
|||
using System; |
|||
using System.IO; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using System.Web; |
|||
using Volo.Abp.Cli.Args; |
|||
using Volo.Abp.Cli.Commands; |
|||
using Volo.Abp.Content; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Http.Client; |
|||
|
|||
namespace LINGYUN.Abp.Cli.Commands; |
|||
|
|||
public class BlobMigrationCommand : IConsoleCommand, ITransientDependency |
|||
{ |
|||
public const string Name = "blob-migration"; |
|||
|
|||
protected string CommandName => Name; |
|||
|
|||
protected IBlobIntegrationService BlobIntegrationService { get; } |
|||
protected ICurrentBlob CurrentBlob { get; } |
|||
public ILogger<BlobMigrationCommand> Logger { protected get; set; } |
|||
|
|||
public BlobMigrationCommand( |
|||
IBlobIntegrationService blobIntegrationService, |
|||
ICurrentBlob currentBlob) |
|||
{ |
|||
BlobIntegrationService = blobIntegrationService; |
|||
CurrentBlob = currentBlob; |
|||
|
|||
Logger = NullLogger<BlobMigrationCommand>.Instance; |
|||
} |
|||
|
|||
public async virtual Task ExecuteAsync(CommandLineArgs commandLineArgs) |
|||
{ |
|||
var workingDirectory = commandLineArgs.Options.GetOrNull(BlobCommandOptions.WorkingDirectory.Short, BlobCommandOptions.WorkingDirectory.Long); |
|||
if (workingDirectory.IsNullOrWhiteSpace()) |
|||
{ |
|||
workingDirectory = Directory.GetCurrentDirectory(); |
|||
} |
|||
if (workingDirectory != null) |
|||
{ |
|||
Logger.LogInformation("Working Directory: {workingDirectory}", workingDirectory); |
|||
} |
|||
|
|||
var searchOption = SearchOption.TopDirectoryOnly; |
|||
var searchOptionArg = commandLineArgs.Options.GetOrNull(BlobCommandOptions.SearchOption.Short, BlobCommandOptions.SearchOption.Long) |
|||
?? "top"; |
|||
if (searchOptionArg != null) |
|||
{ |
|||
Logger.LogInformation("Search Option: {searchOptionArg}", searchOptionArg); |
|||
searchOption = searchOptionArg switch |
|||
{ |
|||
"all" => SearchOption.AllDirectories, |
|||
_ => SearchOption.TopDirectoryOnly, |
|||
}; |
|||
} |
|||
var searchPattern = commandLineArgs.Options.GetOrNull(BlobCommandOptions.SearchPattern.Short, BlobCommandOptions.SearchPattern.Long) |
|||
?? "*.*"; |
|||
if (searchPattern != null) |
|||
{ |
|||
Logger.LogInformation("Search Pattern: {searchPattern}", searchPattern); |
|||
} |
|||
var bucketName = commandLineArgs.Options.GetOrNull(BlobCommandOptions.BucketName.Short, BlobCommandOptions.BucketName.Long) |
|||
?? "blobs"; |
|||
if (bucketName != null) |
|||
{ |
|||
Logger.LogInformation("Bucket Name: {bucketName}", bucketName); |
|||
} |
|||
var pathName = commandLineArgs.Options.GetOrNull(BlobCommandOptions.PathName.Short, BlobCommandOptions.PathName.Long); |
|||
if (pathName != null) |
|||
{ |
|||
Logger.LogInformation("Path Name: {pathName}", pathName); |
|||
} |
|||
var objectName = commandLineArgs.Options.GetOrNull(BlobCommandOptions.ObjectName.Short, BlobCommandOptions.ObjectName.Long); |
|||
if (objectName != null) |
|||
{ |
|||
Logger.LogInformation("Object Name: {objectName}", objectName); |
|||
} |
|||
var baseUrl = commandLineArgs.Options.GetOrNull(BlobCommandOptions.Url.Short, BlobCommandOptions.Url.Long); |
|||
if (baseUrl != null) |
|||
{ |
|||
Logger.LogInformation("Base Url: {baseUrl}", baseUrl); |
|||
} |
|||
var tenantId = commandLineArgs.Options.GetOrNull(BlobCommandOptions.Tenant.Short, BlobCommandOptions.Tenant.Long); |
|||
if (tenantId != null) |
|||
{ |
|||
Logger.LogInformation("Tenant Id: {tenantId}", tenantId); |
|||
} |
|||
|
|||
CurrentBlob.BaseUrl = baseUrl; |
|||
CurrentBlob.TenantId = tenantId; |
|||
var isListFile = commandLineArgs.Options.ContainsKey(BlobCommandOptions.ListFile.Short) |
|||
|| commandLineArgs.Options.ContainsKey(BlobCommandOptions.ListFile.Long); |
|||
var overwrite = commandLineArgs.Options.ContainsKey(BlobCommandOptions.Overwrite.Short) |
|||
|| commandLineArgs.Options.ContainsKey(BlobCommandOptions.Overwrite.Long); |
|||
Logger.LogInformation("Overwrite: {overwrite}", overwrite); |
|||
|
|||
var successd = 0; |
|||
var failed = 0; |
|||
var ignored = 0; |
|||
var files = Directory.GetFiles(workingDirectory, searchPattern, searchOption); |
|||
Logger.LogInformation("In the directory: {directory}, a total of {count} files that match the search pattern: {pattern} were found.", workingDirectory, files.Length, searchPattern); |
|||
|
|||
foreach (var file in files) |
|||
{ |
|||
var defaultBlobPath = Directory.GetParent(file).FullName |
|||
.RemovePreFix(workingDirectory) |
|||
.Replace("\\", "/"); |
|||
var defaultBlobName = Path.GetFileName(file) |
|||
.RemovePreFix(workingDirectory) |
|||
.Replace("\\", "/"); |
|||
var fileName = Path.GetFileName(file); |
|||
var blobPath = pathName ?? defaultBlobPath; |
|||
if (!blobPath.IsNullOrWhiteSpace()) |
|||
{ |
|||
blobPath = blobPath.EnsureEndsWith('/'); |
|||
} |
|||
var blobName = blobPath + (objectName ?? defaultBlobName).RemovePreFix("/"); |
|||
|
|||
if (isListFile) |
|||
{ |
|||
Logger.LogInformation("Container: {containerName}, Blob: {blobName}", bucketName, blobName); |
|||
} |
|||
else |
|||
{ |
|||
Logger.LogInformation("Starting to upload file: {blobName}.", blobName); |
|||
using (var fs = File.OpenRead(file)) |
|||
{ |
|||
try |
|||
{ |
|||
if (!overwrite) |
|||
{ |
|||
var blobExists = await BlobIntegrationService.ExistsAsync( |
|||
new BlobManagement.Integration.Dtos.BlobFileGetByNameIntegrationDto |
|||
{ |
|||
ContainerName = bucketName, |
|||
BlobName = HttpUtility.UrlEncode(blobName), |
|||
}); |
|||
if (blobExists) |
|||
{ |
|||
ignored += 1; |
|||
Logger.LogInformation("File: {blobName} already exists. Skipping the upload of this file!", blobName); |
|||
continue; |
|||
} |
|||
} |
|||
var blobDto = await BlobIntegrationService.CreateAsync( |
|||
new BlobManagement.Integration.Dtos.BlobFileCreateIntegrationDto |
|||
{ |
|||
ContainerName = bucketName, |
|||
BlobName = HttpUtility.UrlEncode(blobName), |
|||
File = new RemoteStreamContent(fs, fileName), |
|||
Overwrite = overwrite, |
|||
}); |
|||
|
|||
if (blobDto != null) |
|||
{ |
|||
successd += 1; |
|||
Logger.LogInformation("File: {blobName} has been uploaded successfully, Id: {id}", blobName, blobDto.Id.ToString()); |
|||
} |
|||
else |
|||
{ |
|||
failed += 1; |
|||
Logger.LogWarning("File: {blobName} upload failed!", blobName); |
|||
} |
|||
} |
|||
catch (AbpRemoteCallException cex) |
|||
{ |
|||
failed += 1; |
|||
Logger.LogWarning("File: {blobName} upload error, Code: {code}, message: {message}", blobName, cex.Code, cex.Message); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
failed += 1; |
|||
Logger.LogWarning("File: {blobName} upload error, message: {message}", blobName, ex.Message); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
if (!isListFile) |
|||
{ |
|||
Logger.LogInformation("{count} file upload tasks have been completed. Ignore: {ignored}, Success: {successd}, Failure: {failed}!", files.Length, ignored, successd, failed); |
|||
} |
|||
} |
|||
|
|||
public static string GetShortDescription() |
|||
{ |
|||
return "Command line for migrating the old version of OssManagement to BlobManagement storage."; |
|||
} |
|||
|
|||
public virtual string GetUsageInfo() |
|||
{ |
|||
var sb = new StringBuilder(); |
|||
|
|||
sb.AppendLine(""); |
|||
sb.AppendLine("Usage:"); |
|||
sb.AppendLine(""); |
|||
sb.AppendLine(" labp blob-migration [options]"); |
|||
sb.AppendLine(""); |
|||
sb.AppendLine("Warning:"); |
|||
sb.AppendLine(""); |
|||
sb.AppendLine("This function is only applicable to the OssManagement integration using the local file system(AbpOssManagementFileSystemModule). Other solutions are not supported at present."); |
|||
sb.AppendLine(""); |
|||
sb.AppendLine("Options:"); |
|||
sb.AppendLine(""); |
|||
sb.AppendLine("-wd|--working-directory <directory-path> (default: Current directory) Execution directory."); |
|||
sb.AppendLine("-so|--search-option <search-option> (default: top) Search for directory file option (top, all)."); |
|||
sb.AppendLine("-sp|--search-pattern <search-pattern> (default: *.*) Search for directory file pattern. Example: *.jpg"); |
|||
sb.AppendLine("-bn|--bucket <bucket-name> (default: blobs) Storage container name"); |
|||
sb.AppendLine("-pn|--path <path-name> Storage file path. The path is parsed from the current file by default."); |
|||
sb.AppendLine("-on|--object <object-name> Store file name. The default is to use the current file name."); |
|||
sb.AppendLine("-u|--url <url> (default: http://localhost:8080) BlobManagement service URL from."); |
|||
sb.AppendLine("-ls|--list-file Only list the files without uploading them. This is for confirming before uploading."); |
|||
sb.AppendLine(""); |
|||
sb.AppendLine("Examples:"); |
|||
sb.AppendLine(""); |
|||
sb.AppendLine(" labp blob-migration -wd D:\\\\Blobs\\\\ -so top -ls"); |
|||
sb.AppendLine(" labp blob-migration -wd D:\\\\Blobs\\\\ -so top -sp *.dll -ls"); |
|||
sb.AppendLine(" labp blob-migration -wd D:\\\\Blobs\\\\ -bn users -ls"); |
|||
sb.AppendLine(" labp blob-migration -wd D:\\\\Blobs\\\\ -bn users -u https://localhost:8443"); |
|||
sb.AppendLine(" labp blob-migration -wd D:\\\\Blobs\\\\ -bn users -pn 8e12e0ce-8534-41d2-af49-da1ff828005a -on a.jpg"); |
|||
sb.AppendLine(" labp blob-migration -wd D:\\\\Blobs\\\\ -bn users -pn 8e12e0ce-8534-41d2-af49-da1ff828005a -on a.jpg -ls"); |
|||
sb.AppendLine(" labp blob-migration -wd D:\\\\Blobs\\\\ -bn users -pn 8e12e0ce-8534-41d2-af49-da1ff828005a -on a.jpg -u https://localhost:8443"); |
|||
sb.AppendLine(" labp blob-migration -wd D:\\\\Blobs\\\\ -bn users -pn 8e12e0ce-8534-41d2-af49-da1ff828005a -on a.jpg -u https://localhost:8443 -t 3a21eaee-36d2-12ad-3f3a-332d7e6e5ac4"); |
|||
sb.AppendLine(""); |
|||
|
|||
return sb.ToString(); |
|||
} |
|||
|
|||
public static class BlobCommandOptions |
|||
{ |
|||
public static class WorkingDirectory |
|||
{ |
|||
public const string Short = "wd"; |
|||
public const string Long = "working-directory"; |
|||
} |
|||
|
|||
public static class SearchOption |
|||
{ |
|||
public const string Short = "so"; |
|||
public const string Long = "search-option"; |
|||
} |
|||
|
|||
public static class SearchPattern |
|||
{ |
|||
public const string Short = "sp"; |
|||
public const string Long = "search-pattern"; |
|||
} |
|||
|
|||
public static class ListFile |
|||
{ |
|||
public const string Short = "ls"; |
|||
public const string Long = "list-file"; |
|||
} |
|||
|
|||
public static class BucketName |
|||
{ |
|||
public const string Short = "bn"; |
|||
public const string Long = "bucket"; |
|||
} |
|||
|
|||
public static class PathName |
|||
{ |
|||
public const string Short = "pn"; |
|||
public const string Long = "path"; |
|||
} |
|||
|
|||
public static class ObjectName |
|||
{ |
|||
public const string Short = "on"; |
|||
public const string Long = "object"; |
|||
} |
|||
|
|||
public static class Tenant |
|||
{ |
|||
public const string Short = "t"; |
|||
public const string Long = "tenant"; |
|||
} |
|||
|
|||
public static class Url |
|||
{ |
|||
public const string Short = "u"; |
|||
public const string Long = "url"; |
|||
} |
|||
|
|||
public static class Overwrite |
|||
{ |
|||
public const string Short = "ow"; |
|||
public const string Long = "overwrite"; |
|||
} |
|||
} |
|||
} |
|||
@ -1,10 +1,24 @@ |
|||
{ |
|||
"profiles": { |
|||
"LINGYUN.Abp.Cli": { |
|||
"Commands.Help": { |
|||
"commandName": "Project", |
|||
"commandLineArgs": "help" |
|||
}, |
|||
"Commands.Create": { |
|||
"commandName": "Project", |
|||
//"commandLineArgs": "generate-view -t vben-view -m auditing -o D:\\Projects\\Development\\view-script -url http://127.0.0.1:30000/" |
|||
// "commandLineArgs": "generate-proxy -t flutter -asp rest-service -u http://127.0.0.1:30000 -m notifications -o D:\\Projects\\Development\\flutter-script -skip-cli-version-check" |
|||
"commandLineArgs": "create MyCompanyName.MyProjectName -t lam -pk MyPackageName -o /Users/feijie/Projects/Tests --dbms MySql --cs \"Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None\" --no-random-port" |
|||
}, |
|||
"Commands.GenerateView": { |
|||
"commandName": "Project", |
|||
"commandLineArgs": "generate-view -t vben-view -m auditing -o D:\\Projects\\Development\\view-script -url http://127.0.0.1:30000/" |
|||
}, |
|||
"Commands.GenerateProxy": { |
|||
"commandName": "Project", |
|||
"commandLineArgs": "generate-proxy -t flutter -asp rest-service -u http://127.0.0.1:30000 -m notifications -o D:\\Projects\\Development\\flutter-script -skip-cli-version-check" |
|||
}, |
|||
"Commands.BlobMigration": { |
|||
"commandName": "Project", |
|||
"commandLineArgs": "blob-migration -so all -sp *.jpg -ls" |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue