summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2017-02-11 14:19:55 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2017-02-11 14:19:55 +0100
commitaf750a6598d53b8a5cb58092dd5b523ea7e967ca (patch)
tree3db935d25763c8bcca87fecf59ed94a43990ba98
parent57fa40103fb866200a254efb9754b4d5d54cd7f9 (diff)
Fixed uploading small files.
For small files the file attribute is a StringIO object instead of a NamedTemporaryFile. For cStringIO we're not allowed to set the delete attribute, so check wether the object already has a delete attribute before attempting to set it.
-rwxr-xr-xfbin.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/fbin.py b/fbin.py
index e1c1853..0f91330 100755
--- a/fbin.py
+++ b/fbin.py
@@ -236,13 +236,15 @@ class Application(object):
return self.redirect(environ, start_response, 'l')
if not user and not settings.allow_anonymous_uploads:
- form['file'].file.delete = True
+ if hasattr(form['file'].file, 'delete'):
+ form['file'].file.delete = True
start_response('403 Forbidden', [('Content-Type', 'text/plain')])
return ['Anonymous uploads are disabled by the administrator.']
filename = form.getvalue('filename')
temp = form['file'].file
- temp.delete = False
+ if hasattr(temp, 'delete'):
+ temp.delete = False
# 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'):