【发布时间】:2018-02-26 19:33:39
【问题描述】:
我正在尝试使用 ASP.NET Core 中的这个库:https://github.com/infusion/jQuery-webcam 来获取从网络摄像头拍摄的照片。
在这个例子中,MVC Capture webcam image, save file path of image to the database,会发生这样的事情:
$(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 () { }
});
});
从视图中调用了名为Capture 的控制器方法: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);
}
在里面,有一个var stream = Request.InputStream;。
问题是在 ASP.NET Core 中没有Request.InputStream。
我可以用什么代替?
【问题讨论】:
标签: c# asp.net asp.net-core