public async Task <IActionResult> Get(string id)
        {
            var loadImageResult = await _imageStorageService.LoadImageAsync(id);

            if (!loadImageResult.IsSuccessful)
            {
                return(GetImageLoadErrorResult(loadImageResult.Error));
            }
            var image = PhysicalFile(loadImageResult.FilePath, loadImageResult.FileMediaType);

            return(image);
        }
Example #2
0
        public async Task <IActionResult> Get([FromRoute] string id)
        {
            _logger.LogInformation($"Getting image with id - {id}");

            var loadImageResult = await _imageStorageService.LoadImageAsync(id);

            if (loadImageResult.IsSuccess)
            {
                _logger.LogInformation($"Getting image with id - {id} success");

                return(File(loadImageResult.Value.File, loadImageResult.Value.FileMediaType));
            }

            var statusCodeResult = GetImageLoadErrorResult(loadImageResult.ErrorType);

            _logger.LogWarning(statusCodeResult.StatusCode.HasValue
                ? $"Getting image with id - {id} failed; Status code - {statusCodeResult.StatusCode.Value}, reason - {statusCodeResult.Value}"
                : $"Getting image with id - {id} failed; Reason - {statusCodeResult.Value}");

            return(statusCodeResult);
        }