Skip to main content
GameDev.net gamedev.net
🔒 Locked

[web] Image Management

Started by sooner123 Aug 29, 2011 at 12:53 PM 1 replies 1.2k views
Original Post
sooner123
sooner123
I'm creating a web-service that allows users to upload photos that can then be viewed by other users.

My question is: what is the best way to file manage this, especially as file names go?

I thought about allowing the user to upload, say shark.jpg and then the database would make a record in the images table as such:
autoID = 13827, uploader = tim33, localFileAlias = shark.jpg, trueFileName = f892y839572inksui90.jpg

trueFileName would be the actual file name on the server in the images directory. And be generated randomly, making sure the file name doesn't already exist. (i don't like hashing for this since if anyone figures out my seeds (user names, localFileAlias, etc.) they'd be that much closer to finding the true file name)

and the true file name being changed every time the file is accessed <-- is this of any value?

-I don't want people to be able to guess file names and view images that another user might want kept private.
-I don't want people to able to arbitrarily URL edit to view random images either.
JustChris
JustChris


and the true file name being changed every time the file is accessed <-- is this of any value?

-I don't want people to be able to guess file names and view images that another user might want kept private.
-I don't want people to able to arbitrarily URL edit to view random images either.


This would be useful if you want to prevent hotlinking. But whether or not you should rename the file every time it's being accessed is debatable.

Some CMSes create randomly named folders where user-uploaded content is stored, and the image gets stored there. Folders are created for each image, based on timestamp and the user that uploaded it. Directory access is forbidden here, so the user won't be able to guess the random name for the next photo.

One thing to keep in mind for the one-picture-per folder scheme is it uses up inodes more quickly. Check your web host to see if you have an inode limit, and how much.
Electronic Meteor - My experiences with XNA and game development
sooner123
sooner123

This would be useful if you want to prevent hotlinking. But whether or not you should rename the file every time it's being accessed is debatable.

Some CMSes create randomly named folders where user-uploaded content is stored, and the image gets stored there. Folders are created for each image, based on timestamp and the user that uploaded it. Directory access is forbidden here, so the user won't be able to guess the random name for the next photo.

One thing to keep in mind for the one-picture-per folder scheme is it uses up inodes more quickly. Check your web host to see if you have an inode limit, and how much.


Yeah. The more I thought about it, the more I realized renaming the file every time it was accessed served little or no purpose and added basically no security on top of what already exists in a random-file-name scheme.

I'm not sure I understand the difference between a folder-per-photo scheme with unguessable folder name and photo name and simply putting all the images in one (directory access forbidden) folder with unguessable random names.

They both seem to accomplish the same thing, yet one without that inode issue you mentioned.

Unless you meant an unguessable folder name, with the original file name inside, thus preserving the original file name. (though this doesn't seem important since the original file name is preserved in the database entry and I don't think that's what you meant anyways)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.