a n
a n

Reputation:

How can I stream documents via a webservice?

I am developing a broker service which accepts a clients request to search for an image with certain tags. I have an existing web service in C# 2.0 which delivers the requested info and due to business rules, I cannot expose my 2.0 webservice to the new client and hence the need for my broker service which will invoke my 2.0 webservice and obtain the handle/location to the image and then try to stream it as the output of the WCF service call

The images could be between 1MB to 20MB in size. What is the best way to stream this data in WCF?

Upvotes: 2

Views: 1332

Answers (2)

Manu
Manu

Reputation: 29153

Use MTOM attachments. See this article for a comparison and explanation.

Upvotes: 2

Ramesh Soni
Ramesh Soni

Reputation: 16077

Change your response type and write your file

Response.ContentType = "image/jpeg";

Response.WriteFile(fileNameAndPath);
Response.End();

alternatively if you have the image loaded in memory

Response.ContentType = "image/jpeg";

Response.OutputStream.Write(imageBytes, 0, bytesLength);
Response.End();

Upvotes: -1

Related Questions