Man, this is weird...
I have a web.py application (0.31) hosted on apache 2+mod_wsgi, that
allows the user to upload files.
Any type of files.
The class handling the upload is:
urls = (
'/' , 'login',
'/login/' , 'login',
'/upload/(.*)$' , 'upload',
'/newFolder/(.*)' , 'newFolder',
'/del/(.*)' , 'delete',
'/search/(.*)$' , 'search',
'/browse/(.*)$' , 'browse',
'/download/(.*)$' , 'download',
'/my(.*)' , 'home',
'/scan/(.*)' , 'scan',
)
...
...
class upload:
'''
Upload a file in a given directory.
The upload process will extract a text only version of some files
(pdf, odt, doc) and store it in the db for quick search abilities
'''
def GET(self, path):
session = init()
logged()
path=cleanPath(path)
msg=getMsg()
return rdr.upload(cfg.frmUp, path, msg)
def POST(self, path):
session=init()
logged()
path=cleanPath(path.encode('utf-8'))
x = web.input(newFile={})
fname=x['newFile'].filename.decode('utf-8')
fname=''.join((c for c in unicodedata.normalize('NFD', fname) if
unicodedata.category(c) != 'Mn'))
web.debug(fname)
finPath=os.path.join(cfg.storePath, path, fname)
web.debug(finPath)
if x.newFile.file:
destFile = open(finPath, 'wb')
destFile.write(x.newFile.file.read())
destFile.close()
web.debug(x.newFile.file.read())
return web.redirect('/browse/%s'%(path))
I live in a french speaking region, and it's not uncommon to have
files named like this "rapport à imprimer.doc"
If I try to upload this file, I have no errors, no warnings, but the
resulting file on the server filesystem have a 0 bytes size.
If I rename the file to "fichier a imprimer.doc" on the client
computer before uploading, I've got the file with it's content.
I've tried to use the normalization of unicodedata to remove the
accents, thinking the problem was maybe when the file was wrote, but
it's not that.
Here is my log output:
[Sun Mar 29 00:57:06 2009] [info] [client 192.168.50.5] mod_wsgi
(pid=26910): Force restart of process 'tmain.ath.cx'.
[Sun Mar 29 00:57:06 2009] [info] mod_wsgi (pid=26910): Shutdown
requested 'tmain.ath.cx'.
[Sun Mar 29 00:57:06 2009] [info] [client 192.168.50.5] mod_wsgi
(pid=25224): Connect after WSGI daemon process restart, attempt #1.,
referer: http://tmain.ath.cx/browse/
[Sun Mar 29 00:57:06 2009] [info] mod_wsgi (pid=26910): Stopping
process 'tmain.ath.cx'.
[Sun Mar 29 00:57:06 2009] [info] mod_wsgi (pid=26910): Destroy
interpreter 'aec.dev|'.
[Sun Mar 29 00:57:06 2009] [info] mod_wsgi (pid=26910): Cleanup
interpreter ''.
[Sun Mar 29 00:57:06 2009] [info] mod_wsgi (pid=26910): Terminating
Python.
[Sun Mar 29 00:57:06 2009] [info] mod_wsgi (pid=26961): Attach
interpreter ''.
[Sun Mar 29 00:57:06 2009] [info] mod_wsgi (pid=26961): Enable monitor
thread in process 'tmain.ath.cx'.
[Sun Mar 29 00:57:06 2009] [info] mod_wsgi (pid=26961): Enable
deadlock thread in process 'tmain.ath.cx'.
[Sun Mar 29 00:57:06 2009] [info] mod_wsgi (pid=26961): Create
interpreter 'aec.dev|'.
[Sun Mar 29 00:57:06 2009] [info] [client 192.168.50.5] mod_wsgi
(pid=26961, process='tmain.ath.cx', application='aec.dev|'): Loading
WSGI script '/var/www/arc_en_ciel/htdocs/base.py'.
[Sun Mar 29 00:57:16 2009] [error] [client 192.168.50.5] u'trye.txt'
[Sun Mar 29 00:57:16 2009] [error] [client 192.168.50.5] u'/var/www/
arc_en_ciel/htdocs/../files/trye.txt'
[Sun Mar 29 00:57:16 2009] [error] [client 192.168.50.5] ''
Does anyone have the slightest idea how to solve this ?
Thierry.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" 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/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---