Contents storing in mysql

2006-11-16 Thread Shain Lee
Hi , 

I wanted to store images , musics, videos ..etc in mysql database.storing 
contents as content type BLOB  , i  don't have any issues with that setup. 
But ,   now i need to store that contents in folders and should be kept the 
contents path with referrence ofcontents file name .

for eample , if i have a image called  sky.jpg . and that image stored in the 
/usr/local/wallpapers/sky.jpg. 
In  my database , i have defined fields like , filename , filesize, imagepath, 
contenttype.

How can i do that ? 
can you give me any help ful links ?

Thanx in advance,
Shaine.


-
 All New Yahoo! Mail – Tired of [EMAIL PROTECTED]@! come-ons? Let our SpamGuard 
protect you.

RE: Contents storing in mysql

2006-11-16 Thread Jerry Schwartz
This work has to be done in a client, since you have to manage external
files. If the files are all uniquely named, then you could use filename as a
key.

In my case, I was linking the images to a product in another table. I used
three tables:

prod_table:
==
prod_num /* an auto-increment key */
... /* other product specific information */

image_table:
===
image_num /* an auto-increment key */
original_image_name /* a key varchar field */
... /* other information about uploaded images, such as file type (.jpg,
.gif) */

prod_image_index:

prod_num /* a key, holds the product number from prod_table */
image_num /* a key, holds the image number from image_table */

Then I name each image the same as its image_num, regardless of its original
name. That avoids any collisions, and allows two images with the same
original name to coexist. When someone uploads an image that goes with a
specific product, I add a record to image_table and prod_image_index and
store the file. If a product is deleted, I can easily find and delete the
related image files when I delete the entries in prod_image_index.

If someone wants to see the images for a particular product, I find them in
prod_image_index. I follow the image_num back to image_table to get the
original file name for the user's convenience. I can then display the image
file (/imgs/1234, say) along with its original_file_name.

If the user then chooses to delete an image, then I delete the file
(/imgs/1234), the corresponding record in image_table, and the corresponding
records in prod_image_index.

I hope that helps.





Regards,

Jerry Schwartz
Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032

860.674.8796 / FAX: 860.674.8341


 -Original Message-
 From: Shain Lee [mailto:[EMAIL PROTECTED]
 Sent: Thursday, November 16, 2006 5:52 AM
 To: MySql
 Subject: Contents storing in mysql

 Hi ,

 I wanted to store images , musics, videos ..etc in mysql
 database.storing contents as content type BLOB  , i  don't
 have any issues with that setup.
 But ,   now i need to store that contents in folders and
 should be kept the contents path with referrence of
 contents file name .

 for eample , if i have a image called  sky.jpg . and that
 image stored in the /usr/local/wallpapers/sky.jpg.
 In  my database , i have defined fields like , filename ,
 filesize, imagepath, contenttype.

 How can i do that ?
 can you give me any help ful links ?

 Thanx in advance,
 Shaine.


 -
  All New Yahoo! Mail - Tired of [EMAIL PROTECTED]@! come-ons? Let our
 SpamGuard protect you.





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Contents storing in mysql

2006-11-16 Thread colbey

If your storing files in mysql, it's best to chunk/shard your data if your
not doing so already.  Example article/code at:

http://www.dreamwerx.net/phpforum/?id=1



On Thu, 16 Nov 2006, Shain Lee wrote:

 Hi ,

 I wanted to store images , musics, videos ..etc in mysql database.storing 
 contents as content type BLOB  , i  don't have any issues with that setup.
 But ,   now i need to store that contents in folders and should be kept the 
 contents path with referrence ofcontents file name .

 for eample , if i have a image called  sky.jpg . and that image stored in the 
 /usr/local/wallpapers/sky.jpg.
 In  my database , i have defined fields like , filename , filesize, 
 imagepath, contenttype.

 How can i do that ?
 can you give me any help ful links ?

 Thanx in advance,
 Shaine.


 -
  All New Yahoo! Mail ? Tired of [EMAIL PROTECTED]@! come-ons? Let our 
 SpamGuard protect you.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]