this is cobbled from a few different routines that are all chained
together....
try:
if filename not in request.POST:
raise UploadError('Missing Param')
file= request.POST[filename]
if file is None:
raise UploadError('Empty Param')
if not hasattr( file , 'filename' ):
raise UploadError("File does not hasattr 'filename'")
# validate the file
if filetype == 'image':
imageFileObject= None
imageObject= None
try:
# try to cache this all
imageFileObject= cStringIO.StringIO()
data= photofile.file.read()
imageFileObject.write(data)
imageFileObject.seek(0)
imageObject= Image.open(imageFileObject)
imageObject.load()
except exceptions.IOError:
raise UploadError('INVALID_FILETYPE')
except :
raise UploadError('INVALID_OTHER')
if not imageObject:
raise UploadError('NO_IMAGE')
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---