existence and size of client file

Discussion in 'Perl Misc' started by Asterbing, Apr 14, 2006.

  1. Asterbing

    Asterbing Guest

    Is there a way to test the existence and size of a client file ? This to
    avoid any unuseful traffic (upload, serveur file test, unlink if too
    big) and report to user as fast as possible (upload limit being high in
    some cases I've to treat ; some tenth of MB).
     
    Asterbing, Apr 14, 2006
    #1
    1. Advertising

  2. Asterbing wrote:
    > Is there a way to test the existence and size of a client file ?


    Depending on what kind of client you are talking about, maybe. Like for
    mirroring systems that's a key functionality.

    But what does that have to do with Perl?

    jue
     
    Jürgen Exner, Apr 14, 2006
    #2
    1. Advertising

  3. Asterbing

    Asterbing Guest

    In article <KhM%f.20266$wH1.3677@trnddc03>, says...
    > Asterbing wrote:
    > > Is there a way to test the existence and size of a client file ?

    >
    > Depending on what kind of client you are talking about, maybe. Like for
    > mirroring systems that's a key functionality.
    >


    Oh no, in framework of a CGI.

    > But what does that have to do with Perl?


    Because I'm talking about CGI written in Perl for which I've to
    incorporate a feature which will allow users to upload a file. So, my
    question was implicitely about Perl, but could be explicitely
    reformulated as this : "Is there a way to test the existence and size of
    a client file in a CGI written in Perl ? -e and -s are server-side only,
    unless mistake.
     
    Asterbing, Apr 14, 2006
    #3
  4. Asterbing wrote:
    > Is there a way to test the existence and size of a client file ? This to
    > avoid any unuseful traffic (upload, serveur file test, unlink if too
    > big)


    Maybe you want to check the $ENV{CONTENT_LENGTH} variable before upload.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Apr 14, 2006
    #4
  5. Asterbing

    Asterbing Guest

    In article <>, says...
    > Asterbing wrote:
    > > Is there a way to test the existence and size of a client file ? This to
    > > avoid any unuseful traffic (upload, serveur file test, unlink if too
    > > big)

    >
    > Maybe you want to check the $ENV{CONTENT_LENGTH} variable before upload.
    >
    >


    Well, but the form will only POST the path to file for uploading, not
    the length of the file data itself.
     
    Asterbing, Apr 14, 2006
    #5
  6. Asterbing wrote:
    > In article <KhM%f.20266$wH1.3677@trnddc03>,
    > says...
    >> Asterbing wrote:
    >>> Is there a way to test the existence and size of a client file ?

    >>
    >> Depending on what kind of client you are talking about, maybe. Like
    >> for mirroring systems that's a key functionality.

    >
    > Oh no, in framework of a CGI.


    I suppose you mean HTTP because for the Commone Gateway Interface there
    isn't really a client unless you call the CGI program the client because the
    other end of the communication line is a web server.

    And no, the HTT-Protocol does not provide any means for such inquiries by
    the server to the client.
    If you think about it it would be quite a security hole if there was such a
    method, wouldn't it?

    >> But what does that have to do with Perl?

    >
    > Because I'm talking about CGI written in Perl


    Which still doesn't make it a question about Perl because your question and
    the answer would be exactly the same even if your CGI program would be
    written in C or LOGO or Pascal or Prolog.

    First of all you have a question about HTTP, then maybe about CGI.

    jue
     
    Jürgen Exner, Apr 14, 2006
    #6
  7. Asterbing

    Asterbing Guest

    In article <9vO%f.9$7w6.2@trnddc02>, says...
    > First of all you have a question about HTTP, then maybe about CGI.
    >


    Seen this way, yes, but I could reformulate indefinitively and a day or
    another find the angle you wish... For example : does -e, -s or open
    authorized to reach client-side files ?
     
    Asterbing, Apr 14, 2006
    #7
  8. Asterbing <> wrote in
    news::

    > In article <9vO%f.9$7w6.2@trnddc02>, says...
    >> First of all you have a question about HTTP, then maybe about CGI.
    >>

    >
    > Seen this way, yes, but I could reformulate indefinitively and a day or
    > another find the angle you wish...


    As someone else mentioned in a different thread recently, I know what the
    words mean but the sentence above makes no sense.

    > For example : does -e, -s or open authorized to reach client-side files ?


    What client? NFS, SSH etc?

    Your question has been answered already: A CGI script running on a web
    server has no way of inspecting the file system on the HTTP client that is
    making the request to the web server.

    The question has nothing whatsoever to do with Perl, and your attempt to
    get cute is not appreciate it.

    Bye.

    Sinan
     
    A. Sinan Unur, Apr 14, 2006
    #8
  9. Asterbing wrote:
    > In article <9vO%f.9$7w6.2@trnddc02>, says...
    >> First of all you have a question about HTTP, then maybe about CGI.
    >>

    >
    > Seen this way, yes, but I could reformulate indefinitively and a day
    > or another find the angle you wish... For example : does -e, -s or
    > open authorized to reach client-side files ?


    Answer:
    Yes, if you are talking about e.g. an NFS client or if files are shared
    between computers.
    No, if you are talking about e.g. an HTTP client.

    Again, which part of "this has nothing to do with Perl but only with your
    application domain" don't you understand?

    jue
     
    Jürgen Exner, Apr 14, 2006
    #9
  10. Asterbing wrote:
    > In article <>, says...
    >>Asterbing wrote:
    >>>Is there a way to test the existence and size of a client file ? This to
    >>>avoid any unuseful traffic (upload, serveur file test, unlink if too
    >>>big)

    >>
    >>Maybe you want to check the $ENV{CONTENT_LENGTH} variable before upload.

    >
    > Well, but the form will only POST the path to file for uploading, not
    > the length of the file data itself.


    True, but $ENV{CONTENT_LENGTH} will hold the length of the whole
    request, and if it exceeds a certain value, it may not be desirable to
    even parse the request.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Apr 14, 2006
    #10
  11. Asterbing

    Asterbing Guest

    In article <Xns97A5730EC30D4asu1cornelledu@132.236.56.8>,
    d says...
    > What client? NFS, SSH etc?
    >


    Any web current browsers.

    > Your question has been answered already: A CGI script running on a web
    > server has no way of inspecting the file system on the HTTP client that is
    > making the request to the web server.
    >


    Well, so, here is my problem, more accurately. I have to provide a way
    for people to upload files which will be limited to, say 100MB. What I
    would like is that user be warned as soon as possible if his file is too
    big.

    Thus, for example, I would like that John submit a 101MB file and be
    warn some minutes later, after unuseful 100MB uploading.

    Is there a way to solve this case using the builtin functions available
    in Perl ?
     
    Asterbing, Apr 14, 2006
    #11
  12. Asterbing

    Asterbing Guest

    In article <bkP%f.28$yQ.0@trnddc07>, says...
    > Again, which part of "this has nothing to do with Perl but only with your
    > application domain" don't you understand?
    >


    Because, I'm searching if Perl built-in fcts allow to solve my problem.
    Just replied to A.Sinan before to read your post.
     
    Asterbing, Apr 14, 2006
    #12
  13. Asterbing

    Asterbing Guest

    In article <>, says...
    > > Well, but the form will only POST the path to file for uploading, not
    > > the length of the file data itself.

    >
    > True, but $ENV{CONTENT_LENGTH} will hold the length of the whole
    > request, and if it exceeds a certain value, it may not be desirable to
    > even parse the request.
    >


    OK, but how does this may help me to figure-out if the submitted file is
    too big (say, >100MB) ?
     
    Asterbing, Apr 14, 2006
    #13
  14. Asterbing

    Guest

    Asterbing <> wrote:
    > In article <>, says...
    > > Asterbing wrote:
    > > > Is there a way to test the existence and size of a client file ? This
    > > > to avoid any unuseful traffic (upload, serveur file test, unlink if
    > > > too big)

    > >
    > > Maybe you want to check the $ENV{CONTENT_LENGTH} variable before
    > > upload.
    > >
    > >

    >
    > Well, but the form will only POST the path to file for uploading, not
    > the length of the file data itself.


    If you are correct and the CGI submission only includes a file path and not
    the actual file data, then the file data must be accessed through the some
    other method; other than CGI. So your question has nothing to do with CGI.
    Since you haven't told us what that other method is...

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Apr 14, 2006
    #14
  15. Asterbing

    Asterbing Guest

    In article <20060414135714.617$>,
    says...
    > Asterbing <> wrote:
    > > In article <>, says...
    > > > Asterbing wrote:
    > > > > Is there a way to test the existence and size of a client file ? This
    > > > > to avoid any unuseful traffic (upload, serveur file test, unlink if
    > > > > too big)
    > > >
    > > > Maybe you want to check the $ENV{CONTENT_LENGTH} variable before
    > > > upload.
    > > >
    > > >

    > >
    > > Well, but the form will only POST the path to file for uploading, not
    > > the length of the file data itself.

    >
    > If you are correct and the CGI submission only includes a file path and not
    > the actual file data, then the file data must be accessed through the some
    > other method; other than CGI. So your question has nothing to do with CGI.
    > Since you haven't told us what that other method is...
    >
    > Xho
    >
    >


    Hum, we have to separate CGI script and CGI script which use CGI.pm.
    Thus, if I'm reading value POSTed about file field, I just get the
    client file path and not a file handle like CGI.pm provide.

    Well, then, if I understand your reply, it means I've to use CGI.pm,
    consider POSTed form contains file data too, and "content-length" is
    usable to define the file length.

    Right ?
     
    Asterbing, Apr 14, 2006
    #15
  16. Asterbing wrote:
    > In article <>, says...
    >>>Well, but the form will only POST the path to file for uploading, not
    >>>the length of the file data itself.

    >>
    >>True, but $ENV{CONTENT_LENGTH} will hold the length of the whole
    >>request, and if it exceeds a certain value, it may not be desirable to
    >>even parse the request.

    >
    > OK, but how does this may help me to figure-out if the submitted file is
    > too big (say, >100MB) ?


    The size of a file to be uploaded is included in the size of the whole
    request.

    I think the raw data are still transmitted, but what you'd gain this way
    is that you wouldn't need to parse the data.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Apr 14, 2006
    #16
  17. Asterbing wrote:
    > Hum, we have to separate CGI script and CGI script which use CGI.pm.
    > Thus, if I'm reading value POSTed about file field, I just get the
    > client file path and not a file handle like CGI.pm provide.


    If you don't use CGI.pm (or an equivalent module), you will have to
    parse the request yourself, and you will find that it indeed includes
    the whole file, not just the name.

    See RFC 1867 for the format.

    hp

    --
    _ | Peter J. Holzer | Löschung von at.usenet.schmankerl?
    |_|_) | Sysadmin WSR/LUGA |
    | | | | Diskussion derzeit in at.usenet.gruppen
    __/ | http://www.hjp.at/ |
     
    Peter J. Holzer, Apr 14, 2006
    #17
  18. Asterbing

    Guest

    Asterbing <> wrote:
    > In article <20060414135714.617$>,
    > says...
    > > Asterbing <> wrote:
    > > > In article <>, says...
    > > > > Asterbing wrote:
    > > > > > Is there a way to test the existence and size of a client file ?
    > > > > > This to avoid any unuseful traffic (upload, serveur file test,
    > > > > > unlink if too big)
    > > > >
    > > > > Maybe you want to check the $ENV{CONTENT_LENGTH} variable before
    > > > > upload.
    > > > >
    > > > >
    > > >
    > > > Well, but the form will only POST the path to file for uploading, not
    > > > the length of the file data itself.

    > >
    > > If you are correct and the CGI submission only includes a file path and
    > > not the actual file data, then the file data must be accessed through
    > > the some other method; other than CGI. So your question has nothing to
    > > do with CGI. Since you haven't told us what that other method is...
    > >
    > > Xho
    > >
    > >

    >
    > Hum, we have to separate CGI script and CGI script which use CGI.pm.


    I don't what that means. You have to separate you CGI scripts that use the
    CGI.pm module from those that don't use CGI.pm but rather use some other
    (home-grown?) CGI-implementing code? What kind of separation do they need,
    and how is that relevant?

    > Thus, if I'm reading value POSTed about file field, I just get the
    > client file path and not a file handle like CGI.pm provide.


    And then what do you do with the client file path once you have it?

    >
    > Well, then, if I understand your reply, it means I've to use CGI.pm,


    No, you do not *have* to. CGI.pm is not magical. You can implement
    yourself anything that CGI.pm normally implements for you. I usually don't
    think that that is a good idea, but in this is not clear that CGI.pm does
    what you need. $CGI::pOST_MAX is there to protect your hard-drive, not your
    network. If $POST_MAX is exceeded, it stills reads the entire data stream
    from the client, it just doesn't save it. That may not be what you want.
    (But the server itself may read the entire request anyway, before it passes
    it on to the CGI.)

    > consider POSTed form contains file data too, and "content-length" is
    > usable to define the file length.


    If you are posting files with file fields using http and CGI, then
    CONTENT_LENGTH should have length, whether you are using CGI.pm module or
    not.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Apr 14, 2006
    #18
  19. Asterbing wrote:
    > In article <bkP%f.28$yQ.0@trnddc07>, says...
    >> Again, which part of "this has nothing to do with Perl but only with
    >> your application domain" don't you understand?
    >>

    >
    > Because, I'm searching if Perl built-in fcts allow to solve my
    > problem.


    Ok, then to answer your particular question: No, the programming language
    Perl does not know anything at all about HTTP or CGI. Nothing, nada, zilch,
    rien. Absolutely nothing. Had you checked "perldoc perlfunc" you probably
    would have noticed that yourself.

    In other words there is no Perl buildin(!) function that would facilitate
    any communication between Perl and an HTTP client.

    jue
     
    Jürgen Exner, Apr 15, 2006
    #19
  20. Asterbing

    robic0 Guest

    On Sat, 15 Apr 2006 00:57:58 GMT, "Jürgen Exner" <> wrote:

    >Asterbing wrote:
    >> In article <bkP%f.28$yQ.0@trnddc07>, says...
    >>> Again, which part of "this has nothing to do with Perl but only with
    >>> your application domain" don't you understand?
    >>>

    >>
    >> Because, I'm searching if Perl built-in fcts allow to solve my
    >> problem.

    >
    >Ok, then to answer your particular question: No, the programming language
    >Perl does not know anything at all about HTTP or CGI. Nothing, nada, zilch,
    >rien. Absolutely nothing. Had you checked "perldoc perlfunc" you probably
    >would have noticed that yourself.
    >
    >In other words there is no Perl buildin(!) function that would facilitate

    ^^^^^^^
    builtin
    I assume..........
    hey Perl is just another dumb programming language.
    Think not???? Let me here it........
    >any communication between Perl and an HTTP client.
    >
    >jue
    >
     
    robic0, Apr 15, 2006
    #20
    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. Matt
    Replies:
    14
    Views:
    2,272
    Rolf Magnus
    Feb 22, 2005
  2. Jim Hunter
    Replies:
    3
    Views:
    612
    Jim Hunter
    Mar 6, 2005
  3. puzzlecracker
    Replies:
    4
    Views:
    276
    Jim Langston
    Oct 31, 2005
  4. Jason Cavett

    Preferred Size, Minimum Size, Size

    Jason Cavett, May 23, 2008, in forum: Java
    Replies:
    5
    Views:
    12,587
    Michael Jung
    May 25, 2008
  5. John Joyce
    Replies:
    2
    Views:
    144
    John Joyce
    Apr 27, 2007
Loading...

Share This Page