添加项目文件。

This commit is contained in:
2026-05-09 17:06:30 +08:00
parent c60f5fe117
commit 720ef957d4
378 changed files with 14843 additions and 0 deletions
@@ -0,0 +1,53 @@
using AutoMapper;
using FileService.Application.Ports;
using FileService.Domain.Entities;
using FileService.Domain.IReposities;
using IM.Commons;
using IM.InitCommon;
using MassTransit.Internals;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FileService.Application.UploadFileTask
{
public class UploadFileTaskService
{
private readonly IUploadTaskReposity reposity;
private readonly IMapper mapper;
private readonly IObjectStorageRouter router;
private readonly IOptions<StorageOptions> options;
public UploadFileTaskService(IUploadTaskReposity reposity, IMapper mapper, IObjectStorageRouter router, IOptions<StorageOptions> options)
{
this.reposity = reposity;
this.mapper = mapper;
this.router = router;
this.options = options;
}
public async Task<Result<TaskInitResponse>> InitTaskAsync(UploadTaskInitCommand command)
{
CancellationToken cancellationToken = CancellationToken.None;
var task = command.ToUploadTask();
var storage = router.Route(options.Value.ProviderCode);
var initRes = await storage.InitUploadAsync(new StorageContracts.InitiateUploadCommand(
ProviderCode: options.Value.ProviderCode,
Bucket: options.Value.Bucket,
ObjectKey: options.Value.Endpoint,
ContentType:task.ContentType.Value,
ContentLength: command.FileSize,
null
), cancellationToken);
var res = mapper.Map<TaskInitResponse>(initRes);
res.TaskId = task.Id;
return Result.Success(res);
}
}
}