summaryrefslogtreecommitdiff
path: root/fbin.py
diff options
context:
space:
mode:
Diffstat (limited to 'fbin.py')
-rwxr-xr-xfbin.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/fbin.py b/fbin.py
index e6a11c1..b7450f1 100755
--- a/fbin.py
+++ b/fbin.py
@@ -159,15 +159,15 @@ class Application(object):
filename = form.getvalue('filename')
temp = tempfile.NamedTemporaryFile(mode = 'wb', prefix = 'fbin', delete = True)
- temp.write(form.getvalue('file'))
- temp.flush()
+ f = form['file'].file
m = hashlib.md5()
- with open(temp.name) as f:
+ s = f.read(128)
+ while len(s):
+ m.update(s)
+ temp.write(s)
s = f.read(128)
- while len(s):
- m.update(s)
- s = f.read(128)
+ temp.flush()
file_hash = m.hexdigest()
f = self.get_file_by_file_hash(file_hash)