[Zope] upload file from filename

Thomas B. Passin tpassin@mitretek.org
Fri, 1 Mar 2002 10:41:20 -0500


[John Hunter]

>
> From a Python Script, given a string which is a filename on the local
> filesystem, say,
>
>     thisFile = 'C:\\ProgramFiles\\SomeDir\\somefile.dat'
>
> How can I upload this to the zope filesystem?
>
> I naively tried:
>
>     folder.manage_addFile(id='somefile.dat', file=thisFile )
>
> But of course this created a file somefile.dat with contents
> 'somefile.dat' because the 'file' argument contains the content, not
> the name, of the file.
>

I don't think you can do this because of security restrictions on scripts.
You can do it easily with some help from an external method, though, because
the external method can get the file's data for you.  On the other hand, you
might want to add some thoughtful checking to provide some security about
what files are allowed to be uploaded.

Of course, that only gets you files that the server computer can access, but
it sounds like that is what you want.

Cheers,

Tom P