Improve memory consumption of file upload with the HTML form

Fix #86
This commit is contained in:
Julien Duponchelle committed 2015-06-10 14:20:06 +02:00
1 parent c10e692ca2
commit b36c5f25d2
2 files changed
+9 -4

No files matched your search

+5 -2
View File
@@ -71,8 +71,11 @@ class UploadHandler:
try:
os.makedirs(destination_dir, exist_ok=True)
with open(destination_path, "wb+") as f:
chunk = data["file"].file.read()
f.write(chunk)
while True:
chunk = data["file"].file.read(512)
if not chunk:
break
f.write(chunk)
st = os.stat(destination_path)
os.chmod(destination_path, st.st_mode | stat.S_IXUSR)
except OSError as e: