I’m stuck, help me out !!!
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
Thanks in advance
First, some notes about your question:
MAC ADDRESS is probably irrelevant, unless you are serving files to your local network. Otherwise it will be meaningless.
IP ADDRESS: you should also consider that if your users are behind a proxy they’ll be accessing your server with the same IP origin, in which case they shouldn’t be blocked.
Answer:
In my opinion the best solution would be to authenticate your users, either with a local account or with openid/googleid/others and then use store the user id on your
FILE_DOWNLOAD_COUNTtable.If using accounts is not an option, I’m afraid you’ll have to manage both cases (IP’s and COOKIES) and expect that the number of users that will circumvent both checks will be relatively small.
Also don’t forget to add some sort of captcha to prevent automated downloads.
This link may be of interest as well, you could attempt to decipher if the user broswer has visited the “download a specific file” before by the fact that it’ll ask the webserver if there is new content or if the page being served is up-to-date. And use this value to create some sort of additional check mechanism (or to increase/decrease the weight of your other mechanisms).