[Zope] File transfer with Zope

Danni Efraim daml@galdrion.com
Tue, 17 Jul 2001 20:00:41 +0200


(my first post to this list, so be merciful =P)

This can be pretty easily done using forms.

Create a form that looks something like this (of course, you'll want to 
customize it):

<form action="fileHandler" method="post" enctype="multipart/form-data">
<input type="file" name="myFile"><input type="submit">
</form>

Then, in whatever method you choose to handle this post (in my example, 
fileHandler), you can manipulate the content of this file as a variable named 
"myFile". If you want to add this as a File object in the subfolder "files", 
you could use the following code:

<dtml-call "files.manage_addFile(id='', file=myFile, title='A textfile')">

See the Zope API-documentation on File objects for more info.

You could also refer to the file in Python, as REQUEST.form['myFile']. This 
can be manipulated as any file, with methods like read() etc. Interesting 
properties also include "filename" and "headers" (the latter contains 
MIME-headers for the file).

Good luck!

/Danni

On Tuesdayen den 17 July 2001 15:45, Nicolas Villetard wrote:
> I use Zope 2.4.
> I'd like to offer users to upload text files to my server in order to
> be manipulated by external methods written in Python.
>
> I have still found only 2 possibilities :
>
> (1) : sending files with a HTML form. But does something exist in
> Python to manage HTTP files sending ??
>
> (2) : sending files by FTP. But how could I access files in Zope's file
> system from an external method ??
> Do libraries exist to manipulate Zope filesystem ?
>
> Your solutions or suggestions are welcomed...
> thanks
>
>
> ____________________________________________________________________
> - http://www.WebMailSPro.com - >>
> VOTRE service d'email sans pub avec VOTRE nom de domaine
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )