[Zope] File Uploads et al
Dieter Maurer
dieter@handshake.de
Sun, 2 Feb 2003 19:08:28 +0100
Samir Mishra wrote at 2003-2-2 10:40 +0400:
> 1) When a user uploads a file, where are the file contents stored in Zope?
> I'm assuming the ZODB database.
You are right.
> 2) How can I provide the user the option of storing uploaded files to a
> directory on the server (directory defined by manager, may be user specific,
> or common to all or group), with a link to (or object representing) the file
> in the user's folder?
You use a product to interfaces Zope objects with files. Examples
are "LocalFS" and "ExtFile".
> 3) What are the security implications of the above scenario?
The same as when you have them in ZODB + the well known ones
that you have them on the file system.
> 4) Or, as in (2), alternate storage is chosen automatically - if the file is
> larger x kb, it's stored in an alternate location/storage. Which Python
> script in Zope handles uploads?
Zope is object oriented. Each class can decide which methods it defines
and how it does it.
Zope's default file object classes are in "OFS.Image" and called
"File" and "Image". Their uploading is implemented by
"OFS.Image.File.manage_upload".
When you want to create different objects based on context,
you must implement this logic, create the necessary objects
and call their "upload" functions.
> 5) Ideally, I'd like to be able to store the file in a database that's
> capable of handling BLOBs, such as Berkeley. Any suggestions?
I really doubt that external databases do it better than the ZODB.
Only put files in them when you really need them there!
> 6) Sometimes, we need to upload the contents of a directory, and not just an
> individual file. The exact contents of the directory can vary. Any easy way
> of doing this?
Zope cannot help you with this, as it is server side technology.
However, your directory contents requires client side technology...
We let our customers make a zip archive from their directory,
upload this file,
and unpack the archive at server side and do what needs to be done...
Dieter