views:

44

answers:

2

Hello everyone, I'm creating a web application using asp.net & WCF as 3 tier architecture, which is mostly looks like a social website. Users can register with the system and they can upload their profile images, documents, video clips etc. So, what i want to know is what is the best way to store those files? In the wcf side or web application side ?

Also I want to know that, if i choose web application side to store those files as set of folders, how it makes those folders shared and allow access to another different project (such as a desktop client need to upload files into that shared folder) ?

thank you all in advance.

A: 

I think the question can better be put like this:

  • save in a folder in the web application or close by and have the metadata stored in a database
  • grab the saved images from a database via WCF

The second approach would likely be rather slow. Grabbing information over a service, convert it, use an httphandler with the correct mime type to spit out the binary stream to the browser...

Most architectures cut down in the middle: save the images close, or in, the UI layer and have the metadata about them stored in the database. Retrieval of that information's mostly just a bunch of strings so easily retrieved.

Update for the new question:

Since winforms applications/other projects were not in your original question this deviates into something new. In that case you go for some of the following scenarios:

  • Use the WCF tier as a common ground and store the images behind that service. As I said it's going to be an extra to pull the byte arrays over.
  • Store the images in the Web UI tier and have a service (asmx or WCF one) to expose the images to your winforms client.
  • Make a share for the winforms client on the server where the web ui runs, and where the images are. Of course be sure to be respectful to security and possible hacks.

It depends on what the most used scenario is. My assumption is that the web ui layer will be mostly used and the the winforms are going to be used for image manipulation? If so there are ASP.NET third party controls available for such manipulation as well so the need for a winforms client would decrease.

XIII
ok thx.I also think the first approach is best for my app. As I mention in my second question, lets say there is a desktop client which is going to upload files into that web application? how can i access those file folders which are close to UI layer(web application)?
arlahiru
If you have a new question I suggest that you start a new thread instead. Small to the point questions have more chance of getting decent answers.
XIII
ok, I'll go for new thread. please check this out http://stackoverflow.com/questions/3362341/how-to-share-a-folder-in-a-asp-net-web-application-with-a-win-form-client
arlahiru
+1  A: 

This depends on how big you expect this thing to get.

If this is for the wider internet and you expect it to get big, having it on the webserver will make it difficult to scale up your application by adding new webservers to your web farm.

One approach would be to have the physical files uploaded to the webserver, to make the uploads quick for users, and then have a coordinator background service that is triggered by an upload, perhaps using a FileWatcher. This service would propogate the file to all nodes in the web farm so that subsequent requests to other nodes will find the file.

If it is a small application intended only for within a company, on the web server is okay, with the following conditions:

  • You have full control over the hosting server so that you can set up the appropriate folder permissions.
  • You write your file saving and retrieving code in such a way that it can be moved onto the lower tiers without too much pain. Do it through an interface and inject the implementation
Daniel Dyson
ok thx. this app will be host in web server and it can be access via internet by any user. The problem is that, if I save it on WCF tier(business tier), then all the time I have to call WCF service to retrieve files. I think it'll be a painful task. Its better if I can save files in the UI layer and save file urls in the Data tier using WCF service as XIII said.
arlahiru
Yes, this is a good approach for performance reasons, but you need to consider if you have more than 1 web server. You will need some way of sharing the files between the multiple webservers. That is why I suggest a combination with a seperate service responsible for the coordination of these files.
Daniel Dyson
yes, that's useful if I'm having more than one web server. But I think there is no chance to host this app in more than one server. So, i think XIII solution is suitable for me.
arlahiru