From 29848a0b8dcfb0c89a55478ba91fe11b30cf016d Mon Sep 17 00:00:00 2001
From: Bryan Tong Minh <bryan.tongminh@gmail.com>
Date: Sat, 20 Sep 2008 22:13:51 +0000
Subject: [PATCH] Don't upload images if there is a connection problem."
 Z:/Documents/Bryan/Mijn documenten/Python/mwclient/trunk/mwclient/client.py

---
 mwclient/client.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/mwclient/client.py b/mwclient/client.py
index f6d869b..0250954 100644
--- a/mwclient/client.py
+++ b/mwclient/client.py
@@ -321,7 +321,8 @@ class Site(object):
 			file.seek(0, 0)
 		
 		predata = {}
-		predata['wpDestFile'] = filename
+		# Do this thing later so that an incomplete upload won't work
+		# predata['wpDestFile'] = filename
 		predata['wpUploadDescription'] = description
 		predata['wpLicense'] = license
 		if ignore: predata['wpIgnoreWarning'] = 'true'
@@ -355,6 +356,12 @@ class Site(object):
 				if not chunk: break
 				yield chunk
 			yield '\r\n'
+			
+			yield '--%s\r\n' % boundary
+			yield 'Content-Disposition: form-data; name="wpDestFile"\r\n'
+			yield '\r\n'
+			yield filename.encode('utf-8')
+			
 			yield '--%s--' % boundary
 			yield '\r\n'
 		
-- 
GitLab