Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: File download tool, file size issues, cgi-application

by salvix (Pilgrim)
on Mar 02, 2006 at 18:12 UTC ( #533995=note: print w/ replies, xml ) Need Help??


in reply to File download tool, file size issues, cgi-application

If your host allows symbolic links in your htdocs (Options FollowSymLinks), you could have the files to be downloaded in another directory outside the htdocs and have a simple CGI script (or mod_perl handler) that:

1- Receives as a parameter the filename to be downloaded

2- Given the current authenticated user, creates a symbolic link of the real file to a file in "/htdocs/downloads/", where the symlink name would be something like filename_USERNAME_MD5GARBAGE.pdf. The MD5GARBAGE would be generated by

my $md5garbage = md5($real_filename, $username, "any random string");
3- Then your CGI redirects the browser (using the Location HTTP header) to the URL http://yoursite/downloads/filename_USERNAME_MD5GARBAGE.pdf.

4- Later on, look into your access log and any successful hit to "filename_username_xxxx.pdf" means that that specific user downloaded that specific file.

5- Periodically, clean up the old symlinks in the /htdocs/downloads/ directory.

(Yeah, it looks like a dirty hack...)


Comment on Re: File download tool, file size issues, cgi-application
Download Code
Re^2: File download tool, file size issues, cgi-application
by chanio (Priest) on Mar 03, 2006 at 16:56 UTC
    1- Receives as a parameter the filename to be downloaded
    ..and could also:
    • 1.a- Compress the file to download
    • 2.a- Know the speed of the connection and mention: bzipped file name, file size and estimated time to download it.
    • 3.a- And, perhaps, even mention the MD5 sum to check with after finishing the download if the user has a way of doing it at his desktop.
    Besides, as a starting point, just try creating an icon at your desktop that points to an ftp file at a well configured ftp site. See how easyly it could work. Then try adding the minimum required to fullfill all your needs.

    And don't forget one of the newest ways of doing such heavy tasks: bittorrent and .torrent files. Similar users get together to improve the download time and diminish the host work.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://533995]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2014-08-21 12:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (135 votes), past polls