From 38ddecbba5f18b65e89976160d95fb91c3498dfd Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Mon, 6 May 2013 18:26:57 +0200 Subject: Fixed uploading very small files. --- fbin.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fbin.py b/fbin.py index 9c8d31d..02200e2 100755 --- a/fbin.py +++ b/fbin.py @@ -245,6 +245,12 @@ class Application(object): filename = form.getvalue('filename') temp = form['file'].file + # If the name attribute is missing, assume this is a StringIO object, then create a new temporary file and copy the contents. + if not hasattr(temp, 'name'): + new_temp = tempfile.NamedTemporaryFile(prefix = 'upload_', dir = settings.file_directory, delete = False) + new_temp.write(temp.getvalue()) + temp = new_temp + m = hashlib.md5() s = temp.read(128) while len(s): -- cgit v1.2.3