This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have got a FILE table with: file_id BIGINT,file_name VARCHAR,file BLOB... etc
I want to count the no of downloads of each file per user/computer so that i can identify the total count of each file and also want to avoid a situation where a single user is downloading the files multiple times,
I just want to know the best way in which it can be implemented, up till now i have thought of following ways:
1) Create a table FILE_DOWNLOAD_COUNT (FILE_ID,UNIQUE_ID) 2) whenever the file is downloaded insert a new record into this table with the ID of the file downloaded and a UNIQUE value corresponding to every download request.
But , what should be used to identfy the UNIQUE_ID???
IP ADDRESS/MAC ADDRESS/A COOKIE Value
ISSUES : IP ADDRESS : At every new connection, a new IP address is assigned (DYNAMIC IP)
MAC ADDRESS: can be changed and MAC spoofing can be used
A COOKIE Value: can be deleted.
So just help me how can i achive this with most reliable way.
FYI: I'm implementing it in JAVA (STRUTS2+Spring) + MYSQL
You can't prevent this completely. All you can do is make it a bit harder. Like you said, the MAC address (which actually isn't sent) can be spoofed. The IP address can be changed, but it can also be shared (thereby blocking users incorrectly). Cookies can be modified as well.
One solution would be to use a login system, but that too doesn't prevent duplicate downloads. I could just create a new account and download with that. Limiting accounts on email addresses won't help either because I can easily create a few hundred email addresses in my own domain if I need to.
sushant verma wrote:I... want to avoid a situation where a single user is downloading the files multiple times...
Why? What difference does it make to you if some user downloads a file twice?
And remember that you can't tell whether a user has downloaded a file. You can tell that the user asked for a file; you can tell that you sent a complete file in response; but you can't tell that the user didn't get the file because of some network or browser failure.