Last post Nov 19, 2007 02:46 AM by Vincent_Liu
Nov 14, 2007 09:24 PM|Vincent_Liu|LINK
I'm trying to make some heavy changes to the PWSSK and make it a multi-user album-sharing website.
And I would like to store image files under directories rather than in the database for easy maintainance. (I would like to store the local urls to the image files in the database)
Could you give me some hints on how to modify the image handler process to separate image files from the database?
Nov 15, 2007 07:43 AM|TATWORTH|LINK
One tip I can give you, is to separate the image root location of this directory (parameterise it) from the file path from the root down and only store the latter in the database.
To find the code just include an image a test aspx page from that directory store and then reverse engineer the HTML necessary to make the display work.
You need to think carefully about permissions to allow the ASP.NET process to read and write from the image root down.
Nov 17, 2007 01:03 PM|whighfield|LINK
As the previous poster has mentioned you probably want to make the directory/file structure simple and database driven. Something like:
The idea is that the folder structure is derived from the different database ID's you would normally have to implement (one or many users have one or many albums which has one or many photos). Only the Photos folder would have to be created; everything
after that can be derived. If you will still take advantage of the original/high/low/thumb feature then the file name of the photos could be <PHOTOID_high.jpg>, <PHOTOID_low.jpg>, <PHOTOID_thumb.jpg>, etc.
As for the Handler it can remain the same except change the retrieve to return the data for the UserID, AlbumID, PhotoID and build the folder path. Then just use the Response.Write() or Response.TransmitFile(). There are probably several examples online
for using each the way you need to.
If you are going to store the path to the file in the database you would only need to query the database to get the url, then use Response.TransmitFile() to do this. There are several sites that also offer code on how to write file to the browser using
Response.Write() just search for "Response.Write() File"
Nov 19, 2007 02:46 AM|Vincent_Liu|LINK