Example #1
0
        public ActionResult GetItem(string fileId)
        {
            try
            {
                GetFileResponse payload = _indexService.GetFile(fileId);
                if (payload == null)
                {
                    return(Responses.NotFoundError(this, $"file {fileId} not found. Id is invalid, or has been deleted."));
                }

                if (payload.Content == null)
                {
                    throw new Exception($"File {fileId} has no content.");
                }

                return(File(payload.Content, "application/octet-stream", payload.FileName));
            }
            catch (InvalidFileIdentifierException)
            {
                return(Responses.InvalidFileId());
            }
            catch (Exception ex)
            {
                _log.LogError(ex, "An unexpected error occurred.");
                return(Responses.UnexpectedError());
            }
        }