|
Post by votan on Aug 8, 2008 6:34:27 GMT -5
I wanna serve some larger files via RB. But need to limit downloads so, that each user can only download 1 file at a time. And as soon as the download has finished or got interrupted, the user can start a new download. Is there a way to do this in RB?
|
|
|
Post by carlgundel on Aug 9, 2008 13:46:55 GMT -5
I wanna serve some larger files via RB. But need to limit downloads so, that each user can only download 1 file at a time. And as soon as the download has finished or got interrupted, the user can start a new download. Is there a way to do this in RB? I'm not completely sure what you mean, but it seems like to begin you would need to track who is logged in. This should not be hard to do. In addition you would need to track what download activity is happening by user. If you're looking to built a scalable system for managing simultaneous downloads by different users then RB would need to be hosted behind Apache or something similar. When the user initiates a download RB would put the desired file into a public folder and given a unique filename. Then you could give the user a link to that URL, or you could force a redirect. Somehow it would be good to get a signal from Apache so that we know the file is completely downloaded. Anyone else have any thoughts on this? -Carl
|
|
|
Post by votan on Aug 9, 2008 20:06:19 GMT -5
Well, running Apache as an underlaying system would probably work, but it would destroy the easynes of using RB.... especially as RB basically is a full featured webserver. And creating renamed copies of the download-file will be a bad thing if there are many simultanous downloads of many big files. I guess the easiest way would be to just set a flag in a DB when a download gets started. So like "has_download = 1". If the download finishes or gets interrupted, the flag gets set back to 0. Only problem is, how to see when the download finished or gets interrupted? I bet the serverplatform of RB could see in some way, if there is an active bitstream to an IP that could return some value to RB!? So if someone wants to start a new download, but "has_download" is 1 and bitstream to requesting IP is active, then it returns an error like "sorry, only one download at a time". If "has_download" is 0 or is 1 and bitstream is inactive, then "has_download" gets reset to 0 and a download is possible again.
I wanna serve a larger number of large files... but to avoid tremendous traffic and slowdowns, I need to make sure that each user can only download 1 file at a time.
This leads me to another problem.... I need to force downloads being done with the browsers standart download routine and not some download managers....
I once had a project where someone wrote a download routine in PHP that does both things.... maybe the code could help to find a way in RB? But not sure though, if it relayed on any special apache features!?
|
|
|
Post by carlgundel on Aug 9, 2008 20:29:33 GMT -5
Well, RB isn't a full featured web server because it isn't a true multi-threaded implementation when serving files. However, running it behind Apache solves that problem for any static content. Perhaps we will be able to add multi-threaded file serving later.
-Carl
|
|
|
Post by kokenge on Aug 9, 2008 21:20:37 GMT -5
This may be a possible way. You would need to know the following: 1. The name of the file they are downloading. 2. The size of the file on the server. 3. Where on the client the file is being downloaded to.
You log the user, file, and start time in a database.
Every time they ask for a file to download, you check it against the DB to see if it's a different file. -- If not different, they are probably restarting the download of the old file again for some reason - probably a restart. So you allow it. -- If different they are asking for another download. In that case you see if the last download is complete. You do this by checking the approximate size of their file to the size of the server file size. If it's close it's probably done, or near it, so you allow this download and log it. If the size is not approximately equal, it is probably still being downloaded and you would not allow another download.
Just a idea that may have possibilities.
Have a great day.. Dan
|
|
|
Post by votan on Aug 10, 2008 12:35:18 GMT -5
Perhaps we will be able to add multi-threaded file serving later. Yes, please do that! kokengeSounds good and actually pretty simple... but that would require access to the clients filesystem... and that would not work without some additional application running on the client machine. Other option could be a javascript downloadmanager (what would suck) or just add an estimated downloadtime to every file, that only allows downloading new files when this time has passed (would also suck). So seems Apache is the only way to do this.... Aynone here who is really good at configuring Apache? Would need then, that Apache only allows one download at a time for each user.... and force downloading via the browsers standart download tool, not any aditionally installed download manager. I remember that I once tried it myself... Apache then simply blocked anything from the user when he was downloading a file... so the user was not able to browse the site anymore as he had to wait for the download to finish... and there was no message coming up for informing the user.... so that was not so well.... and forcing downloads also never really worked.... had to adjust mimi-type settings for that... on some browsers it worked, on others it didn't... So if there is someone here who knows how to do it right in Apache, please be so kind and help. (if possible all be putting the config into the .htaccess file with allow_override on....)
|
|
|
Post by kokenge on Aug 10, 2008 13:28:26 GMT -5
|
|
|
Post by votan on Aug 11, 2008 0:52:01 GMT -5
Thank you.... reading those actually brought me to mod_ipconn, what exactly does what I need! Now the question is, how to set up RB on top of Apache, so that both work together seemlessly?
|
|
|
Post by mackrackit on Aug 11, 2008 18:07:25 GMT -5
|
|