public async Task <DownloadingResult> DownloadLocally(string recordId) { var record = await _facade.GetById(recordId); if (record is null) { throw new ItemNotFoundException($"Record {recordId} does not exists"); } using (var stream = await _facade.Download(record)) { var path = await Save(stream, record); return(new DownloadingResult(record, path)); } }
public async Task <IActionResult> GetBlobDownload(string recordId, [FromQuery] string token) { if (string.IsNullOrEmpty(token)) { return(StatusCode(401, "Not authorized")); } var result = CheckCanAccessFile(token); if (result is null) { return(StatusCode(403, "Unauthorized")); } var record = await _facade.GetById(recordId); var stream = await _facade.Download(record); var contentType = "APPLICATION/octet-stream"; var fileName = record.FileName; return(File(stream, contentType, fileName)); }