Merge branch 'master' of https://gitea.nxsir.cn/nanxun/IM_NEW
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using FileService.Application.Ports;
|
||||
using IM.Commons.IntegrationEvents;
|
||||
using MassTransit;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FileService.Application.EventHandler
|
||||
{
|
||||
public class UploadTaskCompleteEventHandler : IConsumer<UploadTaskCompleteEvent>
|
||||
{
|
||||
private readonly IObjectStorageRouter router;
|
||||
private readonly IStorageRedisCache cache;
|
||||
|
||||
public UploadTaskCompleteEventHandler(IObjectStorageRouter router, IStorageRedisCache cache)
|
||||
{
|
||||
this.router = router;
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<UploadTaskCompleteEvent> context)
|
||||
{
|
||||
var @event = context.Message;
|
||||
var storage = router.Route(@event.ProviderCode);
|
||||
if(@event.ProviderCode == "Local")
|
||||
{
|
||||
await storage.CompleteUploadAsync(new StorageContracts.CompleteUploadCommand(
|
||||
ProviderCode: @event.ProviderCode,
|
||||
Bucket: @event.Bucket,
|
||||
Region: @event.Region,
|
||||
ObjectKey: @event.ObjectKey,
|
||||
UploadSessionId: @event.SessionId,
|
||||
Parts: @event.Parts.Select(s => new StorageContracts.UploadPart(
|
||||
PartNumber: s.PartNumber,
|
||||
ETag: s.ETag,
|
||||
Size: s.Size,
|
||||
Checksum: s.Checksum
|
||||
)).ToList()
|
||||
), context.CancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user