diff --git a/RMuseum/Controllers/ImageController.cs b/RMuseum/Controllers/ImageController.cs index 23389c64..d11985ad 100644 --- a/RMuseum/Controllers/ImageController.cs +++ b/RMuseum/Controllers/ImageController.cs @@ -54,12 +54,21 @@ namespace RMuseum.Controllers if(!string.IsNullOrEmpty(imgPath.ExceptionString)) return BadRequest(imgPath.ExceptionString); - if(!System.IO.File.Exists(imgPath.Result)) + if(string.IsNullOrEmpty(imgPath.Result)) { - return NotFound(); + if(size == "orig") + { + imgPath = _pictureFileService.GetImagePath(img.Result, "norm"); + if (!string.IsNullOrEmpty(imgPath.ExceptionString)) + return BadRequest(imgPath.ExceptionString); + } + else + { + return NotFound(); + } + } - return new FileStreamResult(new FileStream(imgPath.Result, FileMode.Open, FileAccess.Read), size == "orig" ? img.Result.ContentType diff --git a/RMuseum/Services/Implementation/PictureFileService.cs b/RMuseum/Services/Implementation/PictureFileService.cs index d4162c57..1e4867e0 100644 --- a/RMuseum/Services/Implementation/PictureFileService.cs +++ b/RMuseum/Services/Implementation/PictureFileService.cs @@ -258,6 +258,8 @@ namespace RMuseum.Services.Implementation public RServiceResult GetImagePath(RPictureFile image, string sz = "orig") { string fileName = sz == "thumb" ? image.ThumbnailImageStoredFileName : sz == "norm" ? image.NormalSizeImageStoredFileName : image.StoredFileName; + if (string.IsNullOrEmpty(fileName)) + return new RServiceResult(null); return new RServiceResult(Path.Combine(ImageStoragePath, image.FolderName, fileName)); }