[Zope] Newbee- Import file
Dieter Maurer
dieter@handshake.de
Mon, 25 Nov 2002 19:25:53 +0100
Jessica Niewint writes:
> I had a look on the FileLibrary and it's functionality to import a file is
> quit close to that what I got in mind ... but unfortunately only close, not
> exactly:
> I my situation I got a dynamically created pdf File (via mysql/cocoon).
> All I want is to save this dynamically created file somewhere on the server
> (it is the same for cocoon and Zope) or better save the generated pdf File
> directly to the Zope File Library. But how could I do it ? I do not want to
> save the pdf first on my local system and do from there the import to Zope,
> like it is possible with the simple form <import file .... >.
I do not precisely understand your need.
Somehow, the file must come to Zope.
When it comes from a "MySQL" database, then you get the
files content and pass this as a string to
"manage_addFile". It will create a file object with the
given string as content.
You may need to specify "content_type" as guessing it
is more difficult from a string than a "ZPublisher.HTTPRequest.FileUpload"
instance.
You can call "manage_addFile" in e.g. a Python Script or External Method
(it probably will look somewhat like:
"destination.manage_addProduct['OFSP'].manage_addFile(...)")
When your file comes via HTTP, you send the files content
in a POST request to Zope. When the generation
is done with Python, I suggest to use "ZPublisher.Client"
as HTTP client.
When it is done in e.g. Java, there (probably) are similar
tools to send HTTP POST requests.
Dieter