Implement media storage and processing features: update configuration in .env.example and appsettings files, enhance Docker setup for media storage, and add media-related services and database entities. Include ffmpeg for media handling and adjust Kestrel settings for large file uploads.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using LiteCqrs;
|
||||
using TeleWave.Application.Common.Interfaces;
|
||||
using TeleWave.Application.Common.Models;
|
||||
using TeleWave.Domain.Media;
|
||||
|
||||
namespace TeleWave.Application.Media.Register;
|
||||
|
||||
public sealed class RegisterMediaAssetCommandHandler(
|
||||
IAppDbContext dbContext,
|
||||
IMediaStorage storage
|
||||
) : ICommandHandler<RegisterMediaAssetCommand, Result<Guid>>
|
||||
{
|
||||
public async Task<Result<Guid>> Handle(
|
||||
RegisterMediaAssetCommand command,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var extension = Path.GetExtension(command.OriginalFileName).ToLowerInvariant();
|
||||
var asset = MediaAsset.Register(command.OriginalFileName, extension, command.Source);
|
||||
|
||||
await storage.PromoteToOriginalAsync(
|
||||
command.Source,
|
||||
command.SourceToken,
|
||||
asset.Id,
|
||||
extension,
|
||||
cancellationToken
|
||||
);
|
||||
|
||||
dbContext.MediaAssets.Add(asset);
|
||||
return Result.Success(asset.Id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user