File Upload Size

Discussion in 'Python' started by rodmc, Oct 12, 2008.

  1. rodmc

    rodmc Guest

    Hi,

    Is there a way to get the size of a file on a remote machine before it
    is uploaded? I would like to write some form of status counter which
    is updated as a fie is uploaded, and also to use this feature to
    prevent files which are too big from being uploaded.

    Best,

    rod
    rodmc, Oct 12, 2008
    #1
    1. Advertising

  2. On Oct 12, 9:34 am, rodmc <> wrote:
    > Hi,
    >
    > Is there a way to get the size of a file on a remote machine before it
    > is uploaded? I would like to write some form of status counter which
    > is updated as a fie is uploaded, and also to use this feature to
    > prevent files which are too big from being uploaded.
    >
    > Best,
    >
    > rod


    Looks like ftplib does that. Check the docs:
    http://www.python.org/doc/2.5.2/lib/module-ftplib.html

    Mike
    Mike Driscoll, Oct 12, 2008
    #2
    1. Advertising

  3. rodmc

    rodmc Guest

    On 13 Oct, 00:10, Mike Driscoll <> wrote:
    > On Oct 12, 9:34 am, rodmc <> wrote:
    >
    > > Hi,

    >
    > > Is there a way to get the size of a file on a remote machine before it
    > > is uploaded? I would like to write some form of status counter which
    > > is updated as a fie is uploaded, and also to use this feature to
    > > prevent files which are too big from being uploaded.

    >
    > > Best,

    >
    > > rod

    >
    > Looks like ftplib does that. Check the docs:http://www.python.org/doc/2.5.2/lib/module-ftplib.html
    >
    > Mike


    Hi Mike,

    Thanks for this information I will look at it. The only condition is
    that everything must run via a webpage.

    Best,

    rod
    rodmc, Oct 13, 2008
    #3
  4. rodmc wrote:

    > On 13 Oct, 00:10, Mike Driscoll <> wrote:
    >> On Oct 12, 9:34 am, rodmc <> wrote:
    >>
    >> > Hi,

    >>
    >> > Is there a way to get the size of a file on a remote machine before it
    >> > is uploaded? I would like to write some form of status counter which
    >> > is updated as a fie is uploaded, and also to use this feature to
    >> > prevent files which are too big from being uploaded.

    >>
    >> > Best,

    >>
    >> > rod

    >>
    >> Looks like ftplib does that. Check the
    >> docs:http://www.python.org/doc/2.5.2/lib/module-ftplib.html
    >>
    >> Mike

    >
    > Hi Mike,
    >
    > Thanks for this information I will look at it. The only condition is
    > that everything must run via a webpage.


    Which is crucial information and rules out Mike's suggestion.

    And the answer is: no, you can't access file-attributes on remote machines.
    HTTP does require a content-length header though. If that exceeds a certain
    size, you can terminate the connection.

    You need to do that also if the client actually pushes more data than
    announced.

    And progress-counting can be done by counting the already arrived data &
    making e.g. an Ajax-Call to fetch that from the server.

    Diez
    Diez B. Roggisch, Oct 13, 2008
    #4
  5. rodmc

    rodmc Guest

    On Oct 13, 11:55 am, "Diez B. Roggisch" <> wrote:
    > rodmc wrote:
    > > On 13 Oct, 00:10, Mike Driscoll <> wrote:
    > >> On Oct 12, 9:34 am, rodmc <> wrote:

    >
    > >> > Hi,

    >
    > >> > Is there a way to get the size of a file on a remote machine before it
    > >> > is uploaded? I would like to write some form of status counter which
    > >> > is updated as a fie is uploaded, and also to use this feature to
    > >> > prevent files which are too big from being uploaded.

    >
    > >> > Best,

    >
    > >> > rod

    >
    > >> Looks like ftplib does that. Check the
    > >> docs:http://www.python.org/doc/2.5.2/lib/module-ftplib.html

    >
    > >> Mike

    >
    > > Hi Mike,

    >
    > > Thanks for this information I will look at it. The only condition is
    > > that everything must run via a webpage.

    >
    > Which is crucial information and rules out Mike's suggestion.
    >
    > And the answer is: no, you can't access file-attributes on remote machines.
    > HTTP does require a content-length header though. If that exceeds a certain
    > size, you can terminate the connection.
    >
    > You need to do that also if the client actually pushes more data than
    > announced.
    >
    > And progress-counting can be done by counting the already arrived data &
    > making e.g. an Ajax-Call to fetch that from the server.
    >
    > Diez


    Thanks. I have basic file uploading working, however is there a limit
    to what can be uploaded via form? It works perfectly for up to around
    20MB then breaks. Also how do I retrieve the content-length header? I
    am quite new to HTTP programming so sorry for the naive questiomn.

    Best,

    rod
    rodmc, Oct 24, 2008
    #5
  6. > Thanks. I have basic file uploading working, however is there a limit
    > to what can be uploaded via form? It works perfectly for up to around
    > 20MB then breaks.



    There is no limit, but the larger the upload, the larger the chance of a
    failure. I'm currently not exactly sure if there is a way to overcome
    this with a continuous upload scheme for browsers - maybe google helps.

    > Also how do I retrieve the content-length header? I
    > am quite new to HTTP programming so sorry for the naive questiomn.



    That depends on your HTTP-framework/libraries of choice.

    Diez
    Diez B. Roggisch, Oct 24, 2008
    #6
  7. rodmc

    rodmc Guest

    Hi Diez,

    Thanks, I will look on Google again, to date though all examples I
    have used come up against similar problems. As for HTTP framework and
    libraries, I will see what is currently supported. At present I am
    using standard Python libraries.

    Best,

    rod
    rodmc, Oct 24, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. lawrence

    Upload file Check file size

    lawrence, Jun 10, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    9,262
    Craig Deelsnyder
    Jun 10, 2004
  2. Robert Strickland

    File Upload and File Size Limitations

    Robert Strickland, Oct 29, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    4,623
    Lau Lei Cheong
    Nov 1, 2004
  3. =?Utf-8?B?U2FyYXY=?=

    Upload a file without file Upload control - ASP.Net

    =?Utf-8?B?U2FyYXY=?=, Aug 2, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,408
    Bruce Barker
    Aug 3, 2005
  4. DJ Stunks
    Replies:
    1
    Views:
    163
    J. Gleixner
    Jan 23, 2006
  5. Replies:
    7
    Views:
    208
    Tad McClellan
    May 21, 2006
Loading...

Share This Page