24 lines
846 B
C#
24 lines
846 B
C#
using Hutopy.Application.AzureBlobStorage.Constants;
|
|
using Hutopy.Application.Common.Interfaces;
|
|
|
|
namespace Hutopy.Application.Users.Queries.GetCurrentUser;
|
|
|
|
public record GetCurrentUserProfilePictureQuery : IRequest<Stream>;
|
|
|
|
public class GetCurrentUserProfilePictureQueryHandler(
|
|
IIdentityService identityService,
|
|
IBlobStorage blobStorage
|
|
)
|
|
: IRequestHandler<GetCurrentUserProfilePictureQuery, Stream>
|
|
{
|
|
public async Task<Stream> Handle(GetCurrentUserProfilePictureQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var identityUser = await identityService.GetCurrentUserAsync();
|
|
|
|
return await blobStorage.DownloadFileAsync(
|
|
ContainerNames.Users,
|
|
$"{identityUser.Id.ToString()}/{SubDirectoryNames.Profile}/{CommonFileNames.ProfilePicture}",
|
|
cancellationToken);
|
|
}
|
|
}
|