I'm trying to use this library in ASP.NET Core: https://github.com/infusion/jQuery-webcam to get the picture taken from a webcam.
In this example, MVC Capture webcam image, save file path of image to the database, this is what happen:
$(document).ready(function () {
                        $("#Camera").webcam({
                            width: 320,
                            height: 240,
                            mode: "save",
                            swffile: "@Url.Content("~/Scripts/jscam.swf")",
                            onTick: function () { },
                            onSave: function () {
                            },
                            onCapture: function () {
                                webcam.save("@Url.Action("Capture", "TrapActivity", new { id = @Model.Id , pid = @Model.PersonId})");
                            },
                            debug: function () { },
                            onLoad: function () { }
                        });
                   });
A Controller method called Capture is called from the View in this line: webcam.save("@Url.Action("Capture", "TrapActivity", new { id = @Model.Id , pid = @Model.PersonId})");
public ActionResult Capture(string ID)
    {
        var path = Server.MapPath("~/Images/ID_" + ID + ".jpg" );
        //var path1 = "~/Images/test.jpg;";
        var stream = Request.InputStream;
        string dump;
        using (var reader = new StreamReader(stream))
            dump = reader.ReadToEnd();
        if (System.IO.File.Exists(path))
        {
            System.IO.File.Delete(path);
            System.IO.File.WriteAllBytes(path, String_To_Bytes2(dump));
        }
        else System.IO.File.WriteAllBytes(path, String_To_Bytes2(dump));
        return View(ID);
    }
Inside it, there is a var stream = Request.InputStream;.
The problem is that in ASP.NET Core there is NOT a Request.InputStream.
What can I use instead?
Request.Body is the stream you're looking for.
You should use 'Request.Body' instead of InputStream
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With