-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#52 Exposed images via the /Image end point.
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
} |