0

I created a web service for file upload. When I call this webservice I can't find multipart-form data request.

If I call this webservice without a file then it will working fine.

My code is:

Interface code:

[OperationContract]
[WebInvoke(RequestFormat = WebMessageFormat.Json, Method = "POST",   ResponseFormat = WebMessageFormat.Json, UriTemplate = "/GetStream")]
void GetStream(Stream fileUpload);

Message contract code:

public void GetStream(Stream fileUpload)
{
    // here I find null fileUpload object
}
ekad
  • 14,436
  • 26
  • 44
  • 46
mukesh
  • 13
  • 3

1 Answers1

0

Check Request.Files variable.

foreach (string file in Request.Files)
{
      var postedFile = Request.Files[file];
      postedFile.SaveAs(Server.MapPath("~/UploadedFiles") + pelicula.Id);
}
Vojtech B
  • 2,837
  • 7
  • 31
  • 59