Limiting Users Download Size
-
Hi there, I have some files in my website for being downloaded by signed in users. But due to the bandwidth limitation I have to restrict users to download only a specefic size per day for example 100MB per day. Now I'm looking for a way to measure the user's download size. Any help please?
-
Hi there, I have some files in my website for being downloaded by signed in users. But due to the bandwidth limitation I have to restrict users to download only a specefic size per day for example 100MB per day. Now I'm looking for a way to measure the user's download size. Any help please?
You should really have asked this in the ASP.NET forum. Anyway, assuming that you only allow logged in users to download files, on every download request you would get the size of the specified file and see if adding it to the days total would take the user over the limit. I know this seems obvious, but bear with me: the wrinkle you have is in defining what counts as a day - is it based on the last 24 hours activity, or is it based on an arbitrary point such as midnight on the database server. The reason you need to know this is because this will affect your calculation as to the previous day. Now, I would suggest storing the current server time in the database against each download for the user as it will make your calculations easier. Further wrinkles for you to think about. What happens if the user aborts a download and then restarts it? Does this count towards your size limit? How are you going to handle the switch over when the clocks go forwards and backwards by an hour?
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
Hi there, I have some files in my website for being downloaded by signed in users. But due to the bandwidth limitation I have to restrict users to download only a specefic size per day for example 100MB per day. Now I'm looking for a way to measure the user's download size. Any help please?
OK. You should have posted this in one location only. Please don't crosspost as it's rude.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
You should really have asked this in the ASP.NET forum. Anyway, assuming that you only allow logged in users to download files, on every download request you would get the size of the specified file and see if adding it to the days total would take the user over the limit. I know this seems obvious, but bear with me: the wrinkle you have is in defining what counts as a day - is it based on the last 24 hours activity, or is it based on an arbitrary point such as midnight on the database server. The reason you need to know this is because this will affect your calculation as to the previous day. Now, I would suggest storing the current server time in the database against each download for the user as it will make your calculations easier. Further wrinkles for you to think about. What happens if the user aborts a download and then restarts it? Does this count towards your size limit? How are you going to handle the switch over when the clocks go forwards and backwards by an hour?
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
Thanks Pete, for the sake of simplicity lets neglect time restriction. so here we only have the size as a criteria for dowload restriction. for the complete dowloads I don't have any problem but somehow download process become aborted I should have the amount size of downloaded bits because this count towards my limit size.
-
Thanks Pete, for the sake of simplicity lets neglect time restriction. so here we only have the size as a criteria for dowload restriction. for the complete dowloads I don't have any problem but somehow download process become aborted I should have the amount size of downloaded bits because this count towards my limit size.
With a simple database table and a simple query, you should be able to easily limit the user then. All you need do is track the amount of data downloaded against the user by time.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
With a simple database table and a simple query, you should be able to easily limit the user then. All you need do is track the amount of data downloaded against the user by time.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
I know that. My problem here is that how can I figure out how many bits are downloaded. I need a code snippet.
-
I know that. My problem here is that how can I figure out how many bits are downloaded. I need a code snippet.
That really depends on how you are letting them download. If all you are doing is putting onto a response stream and letting them download that (and not worry if they abort out mid transfer), then you simply need to count the bytes you are pushing into the response stream. To be honest, this is probably your best bet as other methods become a lot more complicated.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
That really depends on how you are letting them download. If all you are doing is putting onto a response stream and letting them download that (and not worry if they abort out mid transfer), then you simply need to count the bytes you are pushing into the response stream. To be honest, this is probably your best bet as other methods become a lot more complicated.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
Thanks Pete, I try this
-
Thanks Pete, I try this
No problem. Glad to help.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility