Adds ChangeBanner for Creators

This commit is contained in:
Jonathan Bourdon
2024-08-05 16:32:00 -04:00
parent e617b5ffd3
commit 8f0ed2644b
8 changed files with 30 additions and 56 deletions

View File

@@ -1,6 +1,5 @@
using Hutopy.Application.AzureBlobStorage.Constants;
using Hutopy.Application.Common.Interfaces;
using Hutopy.Application.Utils;
using Microsoft.AspNetCore.Http;
namespace Hutopy.Application.Users.Commands;
@@ -16,19 +15,17 @@ public class UploadProfilePictureCommand : IRequest<IResult>
public class UploadProfilePictureCommandHandler(
IHttpContextAccessor contextAccessor,
IIdentityService identityService,
IAzureBlobStorageService azureBlobStorageService) : IRequestHandler<UploadProfilePictureCommand, IResult>
IBlobStorage blobStorage) : IRequestHandler<UploadProfilePictureCommand, IResult>
{
public async Task<IResult> Handle(UploadProfilePictureCommand request, CancellationToken ct)
{
var contentType = contextAccessor.EnsureContentType();
var identityUser = await identityService.GetCurrentUserAsync();
var url = await azureBlobStorageService.UploadFileAsync(
var url = await blobStorage.UploadFileAsync(
ContainerNames.Users,
$"{identityUser.Id}/{SubDirectoryNames.Profile}/{CommonFileNames.ProfilePicture}",
request.File.OpenReadStream(),
contentType,
request.File.ContentType,
ct);
await identityService.UpdateCurrentUserPortraitUrlAsync(url);

View File

@@ -7,7 +7,7 @@ public record GetCurrentUserProfilePictureQuery : IRequest<Stream>;
public class GetCurrentUserProfilePictureQueryHandler(
IIdentityService identityService,
IAzureBlobStorageService azureBlobStorageService
IBlobStorage blobStorage
)
: IRequestHandler<GetCurrentUserProfilePictureQuery, Stream>
{
@@ -15,7 +15,7 @@ public class GetCurrentUserProfilePictureQueryHandler(
{
var identityUser = await identityService.GetCurrentUserAsync();
return await azureBlobStorageService.DownloadFileAsync(
return await blobStorage.DownloadFileAsync(
ContainerNames.Users,
$"{identityUser.Id.ToString()}/{SubDirectoryNames.Profile}/{CommonFileNames.ProfilePicture}",
cancellationToken);