Skip to content

Commit

Permalink
#52 Exposed images via the /Image end point.
Browse files Browse the repository at this point in the history
  • Loading branch information
djdd87 committed Feb 8, 2022
1 parent 89f54c5 commit 28a7343
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions SynoAI/Controllers/ImageController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.AspNetCore.Mvc;
using System.IO;

namespace SynoAI.Controllers
{
public class ImageController : Controller
{
/// <summary>
/// Return snapshot image as JPEG, either in original size or a scaled down version, if asked.
//// In order to use System.Drawing.Common
//// In Terminal, issue: dotnet add SynoAI package System.Drawing.Common
/// </summary>
[Route("Image/{cameraName}/{filename}")]
public ActionResult Get(string cameraName, string filename)
{
// Get and return the original Snapshot
string path = Path.Combine(Constants.DIRECTORY_CAPTURES, cameraName, filename);
byte[] originalSnapshot = System.IO.File.ReadAllBytes(path);
return File(originalSnapshot, "image/jpeg");
}
}
}

0 comments on commit 28a7343

Please sign in to comment.