I
I
Ilya Livshits2017-03-24 22:17:31
JavaScript
Ilya Livshits, 2017-03-24 22:17:31

How to send FormData to WCF REST containing file and text?

Hello, actually the question is in the topic, how to send a file with some related data via HTTP to a WCF service? An example of incoming data might look like:

[DataContract]
public class D
{
    [DataMember]
    public Stream File { get; set; }
    [DataMember]
    public string Text { get; set; }
}

And the JS code I send is this:
let formData = new FormData();
formData.append("File", params.circuitFile);
formData.append("Text", fileName);
return this.http.post('http://localhost/CircuitOptimizer.Service/start', formData)

Interested in how to correctly implement the method in WCF itself, because no matter how I tried, the file can be sent only if it is not part of formData, but the only parameter. And sending of difficult object interests.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question