Skip to content
Snippets Groups Projects
Commit f4d4698a authored by Dan Michael O. Heggø's avatar Dan Michael O. Heggø
Browse files

[#65] Workaround for non-ascii filename uploads

Quite silly, but until the problem is fixed on the server side,
it seems like this workaround is the best solution there is.
parent b6b7d706
No related branches found
No related tags found
No related merge requests found
...@@ -511,6 +511,21 @@ class Site(object): ...@@ -511,6 +511,21 @@ class Site(object):
postdata = predata postdata = predata
files = None files = None
if file is not None: if file is not None:
# Workaround for https://github.com/mwclient/mwclient/issues/65
# ----------------------------------------------------------------
# Since the filename in Content-Disposition is not used as the
# destination filename, we can pass in some ascii-only dummy name
# to make sure the server accepts it.
fname = 'upload'
name = getattr(file, 'name', None)
if name and name[0] != '<' and name[-1] != '>' and name.find('.') != -1:
ext = name[name.rfind('.') + 1:]
fname = 'upload.{}'.format(ext)
file = (fname, file)
# End of workaround
# ----------------------------------------------------------------
files = {'file': file} files = {'file': file}
wait_token = self.wait_token() wait_token = self.wait_token()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment