Send Binary File as response to webservice
-
I am building a web survey type tool. There is a "reward download" for completing the questionnaire. The Questionnaire result / answers are submitted to a web service, to be stored in the db. What I would like to do, is once the db work is complete - to "send" the file to the client. The files are stored in DB BLOBs. I'd like to avoid writing them to disk (especially FTP-ing them somewhere and then redirecting the client to the file - that just seems messy...) I'd like to cause an http response whereby the user sees the browser's standard file download dialogue?
-
I am building a web survey type tool. There is a "reward download" for completing the questionnaire. The Questionnaire result / answers are submitted to a web service, to be stored in the db. What I would like to do, is once the db work is complete - to "send" the file to the client. The files are stored in DB BLOBs. I'd like to avoid writing them to disk (especially FTP-ing them somewhere and then redirecting the client to the file - that just seems messy...) I'd like to cause an http response whereby the user sees the browser's standard file download dialogue?
I don't have a lot of experience with web services, but were this a plain old web form you would just have to get the blob from the database and store it in a database. Then use MemoryStream to stream it out to the client.
-
I am building a web survey type tool. There is a "reward download" for completing the questionnaire. The Questionnaire result / answers are submitted to a web service, to be stored in the db. What I would like to do, is once the db work is complete - to "send" the file to the client. The files are stored in DB BLOBs. I'd like to avoid writing them to disk (especially FTP-ing them somewhere and then redirecting the client to the file - that just seems messy...) I'd like to cause an http response whereby the user sees the browser's standard file download dialogue?
A call to a web service can not send a file directly to the client. To send a response to the client, you need to send a request from the client. Make a proxy page that gets the data from the database and writes it to the response stream. Make the browser request the page, and it will get the file in return.
--- b { font-weight: normal; }
-
I don't have a lot of experience with web services, but were this a plain old web form you would just have to get the blob from the database and store it in a database. Then use MemoryStream to stream it out to the client.
Thanks for the idea, I gave it a whirl using an MP3 file with nonsense extension ".qwe" - IE just wrote the bytes' ASCII equivalents to the page... It seems to behave the same with Response.WriteFile and Response.TransmitFile If you could provide an example of where you've done this before that would be super. What I'm after is to get the browser to popup its normal... "What would you like to do with this file?... Download / Run?", dialogue.
-
A call to a web service can not send a file directly to the client. To send a response to the client, you need to send a request from the client. Make a proxy page that gets the data from the database and writes it to the response stream. Make the browser request the page, and it will get the file in return.
--- b { font-weight: normal; }
Ah-Ha !!! LightBulb ! You Guys ROCK!!! Many Thanks :-D