public Task <Either <ActionResult, FileInfo> > UploadAncillary(
            Guid releaseId,
            ReleaseAncillaryFileUploadViewModel upload)
        {
            return(_persistenceHelper
                   .CheckEntityExists <Release>(releaseId)
                   .OnSuccess(_userService.CheckCanUpdateRelease)
                   .OnSuccess(async() => await _fileUploadsValidatorService.ValidateFileForUpload(upload.File, Ancillary))
                   .OnSuccess(async() =>
            {
                var releaseFile = await _releaseFileRepository.Create(
                    releaseId: releaseId,
                    filename: upload.File.FileName,
                    type: Ancillary,
                    createdById: _userService.GetUserId(),
                    name: upload.Title,
                    summary: upload.Summary);

                await _contentDbContext.SaveChangesAsync();

                await _blobStorageService.UploadFile(
                    containerName: PrivateReleaseFiles,
                    path: releaseFile.Path(),
                    file: upload.File);

                var blob = await _blobStorageService.GetBlob(
                    PrivateReleaseFiles,
                    releaseFile.Path());

                return await ToAncillaryFileInfo(releaseFile, blob);
            }));
        }
示例#2
0
 public async Task <ActionResult <FileInfo> > UploadAncillary(
     Guid releaseId,
     [FromForm] ReleaseAncillaryFileUploadViewModel upload)
 {
     return(await _releaseFileService
            .UploadAncillary(releaseId, upload)
            .HandleFailuresOrOk());
 }