Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Limiting Users Download Size

Limiting Users Download Size

Scheduled Pinned Locked Moved C#
helptutorialquestion
9 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Majid Shahabfar
    wrote on last edited by
    #1

    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?

    P 2 Replies Last reply
    0
    • M Majid Shahabfar

      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?

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • M Majid Shahabfar

        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?

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • P Pete OHanlon

          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

          M Offline
          M Offline
          Majid Shahabfar
          wrote on last edited by
          #4

          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.

          P 1 Reply Last reply
          0
          • M Majid Shahabfar

            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.

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #5

            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

            M 1 Reply Last reply
            0
            • P Pete OHanlon

              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

              M Offline
              M Offline
              Majid Shahabfar
              wrote on last edited by
              #6

              I know that. My problem here is that how can I figure out how many bits are downloaded. I need a code snippet.

              P 1 Reply Last reply
              0
              • M Majid Shahabfar

                I know that. My problem here is that how can I figure out how many bits are downloaded. I need a code snippet.

                P Offline
                P Offline
                Pete OHanlon
                wrote on last edited by
                #7

                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

                M 1 Reply Last reply
                0
                • P Pete OHanlon

                  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

                  M Offline
                  M Offline
                  Majid Shahabfar
                  wrote on last edited by
                  #8

                  Thanks Pete, I try this

                  P 1 Reply Last reply
                  0
                  • M Majid Shahabfar

                    Thanks Pete, I try this

                    P Offline
                    P Offline
                    Pete OHanlon
                    wrote on last edited by
                    #9

                    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

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups