Hmm, well you certainly can't do it at the browser side.

A well-formed HTTP header should contain a content-length attribute which
you can examine.  However, deciding whether to accept the file or not would
I imagine not be possible inside zope since the whole POST operation is
handled by ZServer, so you probably have to write a cgi script to do it.
For example, if you wanted to stick with python, you could use the cgi
module.  You'd examine the header, and if you were happy, you could pass on
the data in a new POST to zope.  If you were unhappy, you could return a
value from the cgi.

This is all off the top of my head, and I'm sure there must be a nicer way
of doing it than that.  It's not nice having it all outside zope.  but it
should be a start, at least.


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Paul Winkler
> Sent: 11 October 2000 06:52
> To: Zope mailing list
> Subject: [Zope] Re: Upload just file headers?
> Still haven't found an answer, after 4 hours searching the
> egroups archive.
> Just to clarify:
> I need to read the headers of the files BEFORE I upload the
> entire file, because the files may be very large and I need
> to be able to give a warning if the file does not meet
> certain criteria. Example: a jpeg file of 500x400 pixels,
> approx. 200 kb when the application, to be used in an
> application that needs much higher resolution in order to
> look good. I want to avoid wasting 50 seconds or so
> uploading this file just to find out that it's no good.
> If I could upload the first bit of the file (1k should be
> plenty), I could open it with PIL and check the size
> attribute. (I've verified this by doing head --bytes 500
> foo.jpeg > test.jpeg and then opening test.jpeg in python -
> it works even though the file has been truncated.)
> I wrote:
> >
> > I'd like to make a form that looks like the typical file
> > upload form, but will upload ONLY the header of the chosen
> > file.
> > Anyone know how / if this can be done?
> --
> .................    paul winkler    ..................
> slinkP arts:   music, sound, illustration, design, etc.
>            web page:
>       A member of ARMS:
> _______________________________________________
> Zope maillist  -  [EMAIL PROTECTED]
> **   No cross posts or HTML encoding!  **
> (Related lists -
> )

Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to