Пример #1
0
        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));
            }
        }
Пример #2
0
        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));
        }