summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2013-05-06 18:26:57 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2013-05-06 18:26:57 +0200
commit38ddecbba5f18b65e89976160d95fb91c3498dfd (patch)
tree7d45e27b10d060e47242dbdd01f8e8d3f1766934
parent56a4126eb8a856ebf8a0e9c0a054d948656a2f7d (diff)
Fixed uploading very small files.
-rwxr-xr-xfbin.py6
1 files changed, 6 insertions, 0 deletions
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):