Discussion:
I/O operation on close file
Stefano Cossu
2014-04-25 23:11:28 UTC
Permalink
Hello,
I'm new to using Bottle and I'm running into a trivial problem.
I'm uploading some file to a running Bottle application via curl.

My python script:

from bottle import Bottle, abort, debug, request, route, run

debug(True)

@route('/image', method='POST')
def imagePost():
source = request.files.get('source')
source.save('/tmp/blah', overwrite=True))

run(host = 'localhost', port = 5000)


My curl command:
curl -vX POST -F source=@/tmp/test.txt http://localhost:5000/image


And I get:
Traceback (most recent call last):
File "/usr/lib/python3.4/site-packages/bottle.py", line 862, in _handle
return route.call(**args)
File "/usr/lib/python3.4/site-packages/bottle.py", line 1727, in wrapper
rv = callback(*a, **ka)
File "./sspad_server", line 18, in imagePost
source.save('/tmp/blah', overwrite=True)
File "/usr/lib/python3.4/site-packages/bottle.py", line 2389, in save
self._copy_file(fp, chunk_size)
File "/usr/lib/python3.4/site-packages/bottle.py", line 2367, in
_copy_file
read, write, offset = self.file.read, fp.write, self.file.tell()
ValueError: I/O operation on closed file.
127.0.0.1 - - [25/Apr/2014 18:08:19] "POST /image HTTP/1.1" 500 1611


What am I doing wrong?

Thanks,
sc
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Felix Yan
2014-04-27 03:07:35 UTC
Permalink
Post by Stefano Cossu
Hello,
I'm new to using Bottle and I'm running into a trivial problem.
I'm uploading some file to a running Bottle application via curl.
from bottle import Bottle, abort, debug, request, route, run
debug(True)
@route('/image', method='POST')
source = request.files.get('source')
source.save('/tmp/blah', overwrite=True))
run(host = 'localhost', port = 5000)
File "/usr/lib/python3.4/site-packages/bottle.py", line 862, in _handle
return route.call(**args)
File "/usr/lib/python3.4/site-packages/bottle.py", line 1727, in wrapper
rv = callback(*a, **ka)
File "./sspad_server", line 18, in imagePost
source.save('/tmp/blah', overwrite=True)
File "/usr/lib/python3.4/site-packages/bottle.py", line 2389, in save
self._copy_file(fp, chunk_size)
File "/usr/lib/python3.4/site-packages/bottle.py", line 2367, in
_copy_file
read, write, offset = self.file.read, fp.write, self.file.tell()
ValueError: I/O operation on closed file.
127.0.0.1 - - [25/Apr/2014 18:08:19] "POST /image HTTP/1.1" 500 1611
What am I doing wrong?
Thanks,
sc
This looks quite like the test failure I reported:
https://github.com/defnull/bottle/issues/617

Hope it helps.

Regards,
Felix Yan

Loading...