summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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):