Stefano Cossu
2014-04-26 21:22:14 UTC
Hello,
I am writing my first Bottle application and I'm running into problems when
posting a file with curl.
This is some bare bones code I am running:
#!/usr/bin/python
from bottle import request, route, run
@route('/test', method='POST')
def test():
source = request.files.get('file')
source.save('/tmp/blah', overwrite=True)
run(host = 'localhost', port = 5100)
This is my curl command:
curl -v -F file=@test.txt http://localhost:5100/test
And in the console where I'm running the above script I get:
$ ./test
Bottle v0.12.5 server starting up (using WSGIRefServer())...
Listening on http://localhost:5100/
Hit Ctrl-C to quit.
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 "./test", line 7, in test
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 - - [26/Apr/2014 16:13:26] "POST /test HTTP/1.1" 500 745
Same error occurs when I try to read the BytesIO
request.files.get('file').file.
What am I doing wrong here?
Thanks,
Stefano
--
I am writing my first Bottle application and I'm running into problems when
posting a file with curl.
This is some bare bones code I am running:
#!/usr/bin/python
from bottle import request, route, run
@route('/test', method='POST')
def test():
source = request.files.get('file')
source.save('/tmp/blah', overwrite=True)
run(host = 'localhost', port = 5100)
This is my curl command:
curl -v -F file=@test.txt http://localhost:5100/test
And in the console where I'm running the above script I get:
$ ./test
Bottle v0.12.5 server starting up (using WSGIRefServer())...
Listening on http://localhost:5100/
Hit Ctrl-C to quit.
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 "./test", line 7, in test
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 - - [26/Apr/2014 16:13:26] "POST /test HTTP/1.1" 500 745
Same error occurs when I try to read the BytesIO
request.files.get('file').file.
What am I doing wrong here?
Thanks,
Stefano
--
--
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.
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.