aspose file tools*
The moose likes Java in General and the fly likes How to get Count of no. of downloads of a file unique to each user/computer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to get Count of no. of downloads of a file unique to each user/computer" Watch "How to get Count of no. of downloads of a file unique to each user/computer" New topic
Author

How to get Count of no. of downloads of a file unique to each user/computer

sushant verma
Greenhorn

Joined: Jun 08, 2011
Posts: 8
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
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Badal Chowdhary
Ranch Hand

Joined: Apr 26, 2011
Posts: 34

How about using user_id as uniqueid? If one person can make mulitple user accounts in your application, then that itself is a different problem altogether.


Blog: http://badalchowdhary.wordpress.com/
Twitter: http://twitter.com/badalrocks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get Count of no. of downloads of a file unique to each user/computer