Table of Contents

Class BaseFileDownloadController<TGetRequestDto, TQueryDto>

Namespace
Whipstaff.AspNetCore.FileTransfer
Assembly
Whipstaff.AspNetCore.dll

Base class for a controller that serves a file with a mime\type.

public abstract class BaseFileDownloadController<TGetRequestDto, TQueryDto> : Controller, IActionFilter, IAsyncActionFilter, IFilterMetadata, IDisposable where TQueryDto : IAuditableRequest<TGetRequestDto, FileNameAndStreamModel?>

Type Parameters

TGetRequestDto

The type for the api request dto.

TQueryDto

The type for the CQRS query dto.

Inheritance
BaseFileDownloadController<TGetRequestDto, TQueryDto>
Implements
Inherited Members
Extension Methods

Constructors

BaseFileDownloadController(IAuthorizationService, ILogger<BaseFileDownloadController<TGetRequestDto, TQueryDto>>, IMediator, Action<ILogger, string, Exception?>)

Initializes a new instance of the BaseFileDownloadController<TGetRequestDto, TQueryDto> class.

protected BaseFileDownloadController(IAuthorizationService authorizationService, ILogger<BaseFileDownloadController<TGetRequestDto, TQueryDto>> logger, IMediator mediator, Action<ILogger, string, Exception?> viewLogAction)

Parameters

authorizationService IAuthorizationService

Authorization service instance for verifying requests.

logger ILogger<BaseFileDownloadController<TGetRequestDto, TQueryDto>>

Logging framework instance.

mediator IMediator

CQRS handler.

viewLogAction Action<ILogger, string, Exception>

Log Message Action for the View event.

Methods

GetAsync(TGetRequestDto, CancellationToken)

Allows for retrieval of a file.

public Task<IActionResult> GetAsync(TGetRequestDto request, CancellationToken cancellationToken)

Parameters

request TGetRequestDto

The request dto.

cancellationToken CancellationToken

Cancellation token for the process.

Returns

Task<IActionResult>

A Task<TResult> representing the result of the asynchronous operation.

GetMediaTypeHeaderString()

Gets the MIME type for the file.

protected abstract string GetMediaTypeHeaderString()

Returns

string

The mime type.

GetViewPolicyName()

Gets the policy name for authorizing viewing of the file.

protected abstract string GetViewPolicyName()

Returns

string

Policy name.

ViewCommandFactoryAsync(TGetRequestDto, ClaimsPrincipal, CancellationToken)

Gets the Command Factory for the View Command.

protected abstract Task<TQueryDto> ViewCommandFactoryAsync(TGetRequestDto request, ClaimsPrincipal claimsPrincipal, CancellationToken cancellationToken)

Parameters

request TGetRequestDto

The request dto for the api.

claimsPrincipal ClaimsPrincipal

Authentication principal associated with the request.

cancellationToken CancellationToken

Cancellation token for the process.

Returns

Task<TQueryDto>

A Task<TResult> representing the result of the asynchronous operation.