2

I am uploading a file through a WCF service.

 [OperationContract(Name = "UploadManual")]
        [DataContractFormat]
        [WebInvoke(Method = "POST",
                   UriTemplate = "UploadManual/",
                   BodyStyle = WebMessageBodyStyle.Bare,
                   ResponseFormat = WebMessageFormat.Json)]
        string UploadManual(Stream Uploading);

Implementation

public string UploadManual(Stream Uploading)
        {
            using (FileStream writer = File.Create(System.Web.Hosting.HostingEnvironment.MapPath("~/ProductManual/Temp.txt")))
            {
               Uploading.CopyTo(writer);

            }    
            return "Response"
        }

But the file is saved along with meta data as below.

---------------------------acebdf13572468 Content-Disposition: form-data; name="fieldNameHere"; filename="FileName.txt" Content-Type: text/plain File Content ---------------------------acebdf13572468--

But i want only content to be saved in the file. How to resolve the issue?

Priyank
  • 1,353
  • 9
  • 13
  • What does the client sending? – Mikey Dec 18 '15 at 12:11
  • a text file.i am testing it through fiddler. – Priyank Dec 18 '15 at 12:39
  • It seems OK, folowing link does the same, are you sure the client does not send the Meata as a part of the content? [File-Upload-using-WCF-REST-API-and-JavaScript](http://www.codeproject.com/Tips/757991/File-Upload-using-WCF-REST-API-and-JavaScript) – Mikey Dec 18 '15 at 12:54
  • yes i am sure. the metadata is not part of file content. – Priyank Dec 20 '15 at 08:15

0 Answers0