Tim Hicks writes:
Is there an easy way to create a fileupload instance from a string? I am trying to batch convert a load of ExtImage files to give them all different sized preview images, but manage_addExtImage() doesn't accept a string. I am a bit lazy - otherwise, I could look it up for you ;-)
"FileUpload" objects are defined in "ZPublisher.HTTPRequest". The constructor wants a "cgi.FieldStorage" as an argument. Look there, how to get a "FieldStorage" from a string...
Thanks Dieter. As it happens, I'd already stumbled across cgi.FieldStorage, but got a bit lost I'm afraid. I tried -- import cgi import StringIO s = StringIO.StringIO('my test stringio') f = cgi.FieldStorage(s) -- but that's as far as I got. I'm not convinced that actually works, but as it happens, I solved the problem by simply passing in a StringIO object instead of a fileupload instance. That solution was thanks to Gregor. thanks for the pointer. tim