media upload
This commit is contained in:
parent
befaa207d7
commit
0d7da2ea85
33 changed files with 257 additions and 353 deletions
|
@ -0,0 +1,25 @@
|
|||
using Femto.Modules.Media.Contracts.LoadFile.Dto;
|
||||
using Femto.Modules.Media.Data;
|
||||
using Femto.Modules.Media.Infrastructure;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Femto.Modules.Media.Contracts.LoadFile;
|
||||
|
||||
internal class LoadFileQueryHandler(IStorageProvider storage, MediaContext context)
|
||||
: IRequestHandler<LoadFileQuery, LoadFileQueryResult>
|
||||
{
|
||||
public async Task<LoadFileQueryResult> Handle(
|
||||
LoadFileQuery query,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var blob = await context
|
||||
.SavedBlobs.Where(b => b.Id == query.FileId)
|
||||
.SingleAsync(cancellationToken: cancellationToken);
|
||||
|
||||
var data = await storage.LoadBlob(query.FileId.ToString());
|
||||
|
||||
return new(data, blob.Type, blob.Size);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue