My web app consists of images stored in the SQL Server db. And, i have a silverlight app on the client side. The web app would allow clients to download file from the server by triggering the download in the silverlight app. The Silverlight talks to the web service to download the file.
I am trying to understand the file download logic on the web service end. I could come up with following approaches:
1) Read the data from db to memory. Write memory data to a file on server. Return the server path to client. The client would invoke HtmlPage.Window.Navigate method with the url to prompt the user to download the file.
Disadvantage of the approach:
– Data from db needs to be written to file every time to download. Multiple simultaneous file download requests could clog the hard drive space on web server.
Is there any other approach to download the file? Does usage of FILESTREAM provide any better alternatives?
Appreciate your response!
Since you’ve already got the DB with the images in the DB I’ll gloss over the whole “should I store images in the DB question”. I only mention it here because I’m sure that others will comment on it and dock me points for not mentioning that it’s not the best idea. I’ll just answer your question as best I can.
You can have a web service return an image directly. It’s fairly straightforward…
Here’s a code snippet from a web service I wrote just to see if you can do it. Hopefully, you can modify it for your needs.
and then the Asp.Net page that displays the image..