/// <summary> /// GET the file and downloads it. /// </summary> /// <param name="getFileAttachedInputUnitId"></param> /// <returns></returns> public async Task <FileResult> GetFilesById(GetFileAttachedObjectInputUnit getFileAttachedInputUnitId) { var attachedObjectUnit = await _attachedObjectUnitAppService.GetFileAttachedObjecUnit(getFileAttachedInputUnitId); Response.AddHeader("Content-Disposition", "attachment; filename=\"" + attachedObjectUnit.FileName + "\""); return(File(attachedObjectUnit.Bytes, attachedObjectUnit.FileExtension)); }
/// <summary> /// GET the File for Download /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <AttachedObjectUnitDto> GetFileAttachedObjecUnit(GetFileAttachedObjectInputUnit input) { var attachedObjectUnit = await _attachedObjectUnitRepository.GetAsync(input.AttachedObjectId); AttachedObjectUnitDto attachedObjectDto = new AttachedObjectUnitDto(); var binaryObject = await _binaryObjectRepository.GetAsync(attachedObjectUnit.UserAttachmentFilesId.GetValueOrDefault()); Mapper.Map(attachedObjectUnit, attachedObjectDto); attachedObjectDto.Bytes = binaryObject.Bytes; return(attachedObjectDto); }