From caa051abae96e0a45ac305040e8c3cb276d07b97 Mon Sep 17 00:00:00 2001 From: Bill Dengler Date: Tue, 2 May 2017 20:55:43 +0000 Subject: [PATCH] Close #130 --- src/extra/AudioUploader/transfer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/extra/AudioUploader/transfer.py b/src/extra/AudioUploader/transfer.py index ca5a6ff3..080d00d4 100644 --- a/src/extra/AudioUploader/transfer.py +++ b/src/extra/AudioUploader/transfer.py @@ -22,7 +22,8 @@ class Upload(object): self.local_filename=os.path.basename(self.filename) if isinstance(self.local_filename, unicode): self.local_filename=self.local_filename.encode(sys.getfilesystemencoding()) - self.m = MultipartEncoder(fields={field:(self.local_filename, open(self.filename, 'rb'), "application/octet-stream")}) + self.fin=open(self.filename, 'rb') + self.m = MultipartEncoder(fields={field:(self.local_filename, self.fin, "application/octet-stream")}) self.monitor = MultipartEncoderMonitor(self.m, self.progress_callback) self.response=None self.obj=obj @@ -66,6 +67,7 @@ class Upload(object): def complete_transfer(self): if callable(self.completed_callback): self.completed_callback(self.obj) - + if hasattr(self,'fin') and callable(self.fin.close): + self.fin.close() def get_url(self): return self.response.json()['url']