Last post Dec 11, 2015 04:35 PM by damienBod
Dec 11, 2015 11:14 AM|Kelmen|LINK
I'm working a method to capture uploading file
it's slightly different with those sample code googled, this Api accept 1 parameter, an object. within has a byte data, which I will fill it with the file .
when testing, i'm getting The request entity's media type 'multipart/form-data' is not supported for this resource
so googling hinting me to add this type to global formatter
protected void Application_Start()
var jsonSupportedEncodings = GlobalConfiguration.Configuration.Formatters.JsonFormatter.SupportedEncodings;
public class UploadMultipartMediaTypeFormatter : System.Net.Http.Formatting.MediaTypeFormatter
public override bool CanReadType(Type type)
public override bool CanWriteType(Type type)
initially i return true for CanWriteType, and for unknown reason, my client test app will get 500 error, and no details.
after changing CanWriteType to false, now I'm getting err:
The media type formatter of type 'UploadMultipartMediaTypeFormatter' does not support reading because it does not implement the ReadFromStreamAsync method
Does anyone have any reference to get this done right?
I'm spending time to tackling this multipart/form-data, but isn't this is a general stuff on web platform, I can't find built-in class of this, do I really need to create this myself?
And I'm not sure about the Can* property, I just wanna get into the uploading testing.
Dec 11, 2015 04:35 PM|damienBod|LINK
here's an example with code.
you should not need to create your own MediaFormatter for this as it is part of the NuGet packages