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);
            }));
        }
        public Task <Either <ActionResult, FileInfo> > UploadAncillary(Guid releaseId, IFormFile formFile, string name)
        {
            return(_persistenceHelper
                   .CheckEntityExists <Release>(releaseId)
                   .OnSuccess(_userService.CheckCanUpdateRelease)
                   .OnSuccess(async() => await _fileUploadsValidatorService.ValidateFileForUpload(formFile, Ancillary))
                   .OnSuccess(async() =>
            {
                var file = await _fileRepository.Create(
                    releaseId,
                    formFile.FileName,
                    Ancillary);

                await _contentDbContext.SaveChangesAsync();

                await _blobStorageService.UploadFile(
                    containerName: PrivateFilesContainerName,
                    path: file.Path(),
                    file: formFile,
                    options: new IBlobStorageService.UploadFileOptions
                {
                    MetaValues = GetAncillaryFileMetaValues(
                        filename: file.Filename,
                        name: name)
                }
                    );

                var blob = await _blobStorageService.GetBlob(
                    PrivateFilesContainerName,
                    file.Path());

                return file.ToFileInfo(blob);
            }));
        }
 public Task <Either <ActionResult, ImageFileViewModel> > Upload(Guid releaseId, IFormFile formFile)
 {
     return(_persistenceHelper
            .CheckEntityExists <Release>(releaseId)
            .OnSuccess(_userService.CheckCanUpdateRelease)
            .OnSuccess(async() => await _fileUploadsValidatorService.ValidateFileForUpload(formFile, Image))
            .OnSuccess(async() => await Upload(
                           releaseId,
                           Image,
                           formFile))
            .OnSuccess(fileInfo => new ImageFileViewModel($"/api/releases/{releaseId}/images/{fileInfo.Id}")
     {
         // TODO EES-1922 Add support for resizing the image
     }));
 }