| Author |
Topic |
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2003-10-23 : 13:54:22
|
| I am creating a part of my website with private galleries for each user. I need to come up with a filename for each file that other users cant guess.Currently it is just ( usersID + "pic1" ).I was thinking of creating a table in my database with 2 columns. Just the userID and guid, each row would represent a picture in the private gallery.However, GUID's are quite large and possibly unnecessary in this case. If I am going to have 500,000 extra pics x 16 bytes the guid itself is going to take up 7814kb of space. Maybe its not the end of the world. I'm just going to speed increases where I can.Do I really need this? Is there a better option? Perhaps a random integer? Anybody use this strategy?Also does anybody have anything against dropping 500,000 files in the same directory? Forsee any problems?Thanks again guys!Mike123 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-10-23 : 14:01:18
|
| Even if you used a random integer, it is still possible that the user could pick that as a file name. If GUID is too large for you, you might want to consider something like timestamp. Timestamp is 8 bytes and is guaranteed to be unique in a database according to BOL.But 7,814kb of space is under 8MB!Tara |
 |
|
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2003-10-23 : 14:04:56
|
| Thanks tarahah I guess 8Mb isnt alot for storage. I'm not really concerned about that, its just this will be queried 100,000's of times daily.Anyways I just thought this.What if I had an identity column (INT), and the userID. This identity column would constantly be changing and I could append that to the filename. Or do you think I should just opt for the GUID.Thanks for your help!mike123 |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-10-23 : 14:10:54
|
| If you go the INT route, whether it be an identity column or not, you're going to need to code for the chance that a user uses the same name. When this happens, just tell the user to select a different name. Or maybe have a directory for each user so that you could have multiple files named the same but in different people's galleries.Tara |
 |
|
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2003-10-23 : 16:49:55
|
| Thanks for the input tara!Does anyone else have any opinions on what I should do? Or what you would do? I'd really, really like to here themcheers,mike123 |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-10-23 : 16:59:22
|
| OK...why would you want to have the exact same file with a different name?Anyway, why not let them pick somethingUserId_UserKeyword_file.jpgAnd what type of "Art" are we talking about?Brett8-) |
 |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2003-10-23 : 17:04:14
|
Probably not the Art you were thinking about Brett Time for another Martini.Sam |
 |
|
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2003-10-23 : 17:31:52
|
hahah .. not its not porn if thats what you are thinking. Its not going to be the exact same file, each user will be able to upload 20 photos of thier choice. anyways the reason I dont let them chose is incase some trend occurs where everybody goes "1", "2", "3" and effectively makes their own galleries public ..thanks again .. mike123 |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-10-23 : 17:40:07
|
| A directory structure would fix that problem, wouldn't it? You're going to end up with thousands of files in one directory. Wouldn't it be more manageable if each user had their own directory? Kind of like "My Documents" on a Windows machine.Tara |
 |
|
|
Granick
Starting Member
46 Posts |
Posted - 2003-10-23 : 18:58:20
|
| We had to do something similar to this, and I chose to use directory structure, using the User's ID followed by a dash, and then a string of 8 random alpha numberics for the directory name.Something like:123-AHRTREWSThat way, when I want to find their directory, I just search for the UserID- and it will get me the directory. This will also prevent anyone from really having any chance of just "guessing" what another user's directory is.The best part is, that I don't have to store the directory string anywhere, as the UserID will get you what you need.We were using ASP.Net on the front end to do the directory. I know this doesn't answer the filename question, but this structure has worked well for us and it might fit your needs.Shannon |
 |
|
|
|