I'm trying to get write Controller (in asp.net core) code to handle my fineuploader requests but it keeps failing to see the request data despite whatever combination of [FromForm] / [FromBody] / "Content-Type": 'application/json' I use. Here is my uploader config in the view page:
var uploader = new qq.FineUploader({
element: document.getElementById("uploader"),
request: {
endpoint: '@Url.Action("AddAttachment", "Util")',
customHeaders: {
"RequestVerificationToken": '@GetAntiXsrfRequestToken()',
"Content-Type": 'application/json'
}
},
And here is my controller code - not alot for now, I just literally want to see some data getting sent.
public JsonResult AddAttachment([FromForm] Object o){
//var x = HttpContext.Request;
//return Json(x);
if(o == null){
return Json("no data");
}else{
return Json(o);
}
}
and her is what I see fineuploader sending to the server via the network tab in the chrome devtools:
------WebKitFormBoundarySQwYoYovQOkoFU1f
Content-Disposition: form-data; name="test"
876
------WebKitFormBoundarySQwYoYovQOkoFU1f
Content-Disposition: form-data; name="qquuid"
9ba04b80-b3d8-4e2d-8068-792dd77253bd
------WebKitFormBoundarySQwYoYovQOkoFU1f
Content-Disposition: form-data; name="qqfilename"
dohPlayDat.PNG
------WebKitFormBoundarySQwYoYovQOkoFU1f
Content-Disposition: form-data; name="qqtotalfilesize"
3535659
------WebKitFormBoundarySQwYoYovQOkoFU1f
Content-Disposition: form-data; name="qqfile"; filename="dohPlayDat.PNG"
Content-Type: image/png
------WebKitFormBoundarySQwYoYovQOkoFU1f-
Can anyone see the mistake I'm making?
If everything's wired up correctly, you should be able to see your file via Request.Form.Files
in the controller.
I was trying to get it as a byte array by action's parameters but had no luck. Try this instead.