Skip to content

Instantly share code, notes, and snippets.

@JoshAshby
Created December 3, 2011 22:30
Show Gist options
  • Save JoshAshby/1428350 to your computer and use it in GitHub Desktop.
Save JoshAshby/1428350 to your computer and use it in GitHub Desktop.
Quick little think about "streaming" data with web.py
'''
This is in a POST/PUT API call which receives a picture (part of my House-Inventory-API)
built with web.py
pic is defined earlier in the program as:
bobbins= web.input(picture={})
pic = bobbins['picture']
and f:
f = open(abspath + '/pictures/' + frodo, "wb")
'''
while 1:
chunk = pic.file.read(10000)
if not chunk:
break
f.write( chunk )
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment