Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion minio/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@
# if math.ceil returns an integer and devide two integers returns a float, calculate
# part size will cause errors, so make sure division integers returns a float.
from __future__ import division
import io

from __future__ import unicode_literals
# future_str is unicode or str in both Python 2 and 3
from builtins import str as future_str

import io
import collections
import base64
import hashlib
Expand Down Expand Up @@ -654,6 +658,16 @@ def optimal_part_info(length, part_size):
def amzprefix_user_metadata(metadata):
m = dict()
for k,v in metadata.items():
# Check if metadata value has US-ASCII encoding since it is
# the only one supported by HTTP headers. This will show a better
# exception message when users pass unsupported characters
# in metadata values.
try:
if isinstance(v, future_str):
v.encode('us-ascii')
except UnicodeEncodeError:
raise ValueError('Metadata supports only US-ASCII characters.')

if is_amz_header(k) or is_supported_header(k) or is_storageclass_header(k):
m[k] = v
else:
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
]

requires = [
'future',
'urllib3',
'pytz',
'certifi',
Expand Down