Skip to content

Commit

Permalink
Fix uploading files with Unicode names (Python 2.7) (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
illia-v authored and ob-stripe committed Dec 31, 2019
1 parent 84241f3 commit 47552da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stripe/multipart_data_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def add_params(self, params):
# Convert the filename to string, just in case it's not
# already one. E.g. `tempfile.TemporaryFile` has a `name`
# attribute but it's an `int`.
filename = str(value.name)
filename = stripe.six.text_type(value.name)

self._write('Content-Disposition: form-data; name="')
self._write(key)
Expand Down
5 changes: 5 additions & 0 deletions tests/test_multipart_data_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,8 @@ def test_multipart_data_file_binary(self):
def test_multipart_data_stringio(self):
string = six.StringIO("foo")
self.run_test_multipart_data_with_file(string)

def test_multipart_data_unicode_file_name(self):
string = six.StringIO("foo")
string.name = u"паспорт.png"
self.run_test_multipart_data_with_file(string)

0 comments on commit 47552da

Please sign in to comment.