Code to receive file via POST

1

I'm doing a webAPI to receive files via post.

The client will send via classic vb with the following code:

Set content = CreateObject("MSXML2.XMLHTTP.6.0")
content.Open "POST", url, False
content.setRequestHeader "TOKEN", token    
content.Send (ConteudoXML)
STR=content.readystate 
ST=content.status
ST_TXT=content.statusText
ws  = content.responseText
Response.write "<br>Status Read:" & STR & "<br>Status:" & ST    & "<br>Status TXT:" & ST_TXT   & "<br>Resposta:" & ws
Set content = Nothing

It is using ASP 1.0, so the sending code can not be changed.

The receiving code I'm using is

if (!Request.Content.IsMimeMultipartContent("form-data")) {
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
}

var sPath = HttpContext.Current.Server.MapPath("~/certificados/");

var re = Request;
var headers = re.Headers;

MultipartFormDataStreamProvider provider = new MultipartFormDataStreamProvider(sPath);

var task = Request.Content.ReadAsMultipartAsync(provider);

return new HttpResponseMessage(HttpStatusCode.Created);

The problem is that the receive code is not recognizing the file and is always returning HttpStatusCode.UnsupportedMediaType.

I will need to receive a file that is in another format (.pfx) as well.

    
asked by anonymous 20.09.2016 / 14:34

0 answers