gpt4 book ai didi

c# - ASP.NET Core 中的 Request.InputStream

转载 作者:太空狗 更新时间:2023-10-29 17:35:39 36 4
gpt4 key购买 nike

我正在尝试在 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 的 Controller 方法在这一行中从 View 调用:webcam.save("@Url.Action("Capture", "TrapActivity", new { id = @模型.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

我可以用什么代替?

最佳答案

Request.Body是您要查找的流。

关于c# - ASP.NET Core 中的 Request.InputStream,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48995809/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com