Skip to content

Commit 28a7343

Browse files
committed
#52 Exposed images via the /Image end point.
1 parent 89f54c5 commit 28a7343

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

SynoAI/Controllers/ImageController.cs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using System.IO;
3+
4+
namespace SynoAI.Controllers
5+
{
6+
public class ImageController : Controller
7+
{
8+
/// <summary>
9+
/// Return snapshot image as JPEG, either in original size or a scaled down version, if asked.
10+
//// In order to use System.Drawing.Common
11+
//// In Terminal, issue: dotnet add SynoAI package System.Drawing.Common
12+
/// </summary>
13+
[Route("Image/{cameraName}/{filename}")]
14+
public ActionResult Get(string cameraName, string filename)
15+
{
16+
// Get and return the original Snapshot
17+
string path = Path.Combine(Constants.DIRECTORY_CAPTURES, cameraName, filename);
18+
byte[] originalSnapshot = System.IO.File.ReadAllBytes(path);
19+
return File(originalSnapshot, "image/jpeg");
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)