Hi,
I have developed a REST based WCF Service (Web role). The service exposes two methods: 1) Upload a file 2) Download file.
- Upload file method accepts the file content as stream and saves in the Azure blob storage, and this functionality is working fine.
- Download file: This method reads the blob from Azure storage and returns the stream. In this I am able to successfully load the content into memorystream and return it, but on the client side the content of the response is 0.
The OperationContract for download method:
[WebGet(UriTemplate = "/{filename}")] [OperationContract] Stream DownloadFile(string filename);
Implementation of DownloadFile:
public Stream DownloadFile(string filename) { MemoryStream stream = new MemoryStream(); // Load the content into the stream from the blob WebOperationContext.Current.OutgoingResponse.ContentType = "application/octet-stream"; return stream; }
Service.svc file content: (uses WebServiceHostFactory for service host)
<%@ ServiceHost Language="C#" Debug="true" Service="TestService.Test" CodeBehind="TestService.svc.cs" Factory="System.ServiceModel.Activation.WebServiceHostFactory"%>
Do I have to do some additional configurations for downloading? If no additional configurations required then what could be possible reasons (coding mistake or deployment issues) for download functionality not working?
Regards,
Tanish Sr.