existence and size of client file

A

Asterbing

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).
 
J

Jürgen Exner

Asterbing said:
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
 
A

Asterbing

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.
 
G

Gunnar Hjalmarsson

Asterbing said:
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.
 
A

Asterbing

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.
 
J

Jürgen Exner

Asterbing said:
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?
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
 
A

Asterbing

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 ?
 
A

A. Sinan Unur

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
 
J

Jürgen Exner

Asterbing said:
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
 
G

Gunnar Hjalmarsson

Asterbing said:
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.
 
A

Asterbing

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 ?
 
A

Asterbing

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.
 
A

Asterbing

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) ?
 
X

xhoster

Asterbing said:
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
 
A

Asterbing

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 ?
 
G

Gunnar Hjalmarsson

Asterbing said:
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.
 
P

Peter J. Holzer

Asterbing said:
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
 
X

xhoster

Asterbing said:
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
 
J

Jürgen Exner

Asterbing said:
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
 
R

robic0

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........
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top