Question

I would like that users of my ZOPE/Plone website can upload (big) file (>1Gb) on a server.

I have a form in html :

<form enctype="multipart/form-data" action="upload.py" method="post">
<p>File: <input type="file" name="file"></p>
<p><input type="submit" value="Upload"></p>
</form>

I have an external script with ZOPE : upload.py

def get(self, REQUEST):
    filename = REQUEST.file['file']

Unfortunately I don't know what to do with this file..

I found some tutorial but I think I'm on wrong way (because these methods can't work with ZOPE ?):

CGI : http://webpython.codepoint.net/cgi_file_upload

ftplib : Python Script Uploading files via FTP

Thanks for your advices,

Was it helpful?

Solution

It depends on how and where you want to store it.

The REQUEST.file is a file object where you can read, seek, tell etc the contents from.

You can store it like a blob:

from ZODB.blob import Blob
blob = Blob()
bfile = blob.open('w')
bfile.write(REQUEST.file)
bfile.close()
# save the blob somewhere now
context.myfile = blob
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top