Created
December 3, 2011 22:30
-
-
Save JoshAshby/1428350 to your computer and use it in GitHub Desktop.
Quick little think about "streaming" data with web.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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