1. David Larlet
  2. django-storages
  3. Issues

Issues

Issue #101 new

TypeError: character mapping must return integer, None or unicode

Jonas Obrist
created an issue

I'm trying to use the S3Backend:

{{{

!python

from storages.backends.s3 import S3Storage from django.core.files.base import ContentFile

storage = S3Storage() storage.save('test.txt', ContentFile('testcontent'))

}}}

Fails in ipython with:

{{{

!traceback

In [10]: storage.save('test.txt', ContentFile('testcontent')) ERROR: An unexpected error occurred while tokenizing input The following traceback may be corrupted or invalid The error message is: ('EOF in multi-line statement', (50, 0)) ERROR: An unexpected error occurred while tokenizing input The following traceback may be corrupted or invalid The error message is: ('EOF in multi-line statement', (51, 0))


TypeError Traceback (most recent call last) /home/jonas/workspace/mysite/<ipython-input-10-7e9e28f5104e> in <module>() ----> 1 storage.save('test.txt', ContentFile('testcontent'))

/home/jonas/workspace/mysite/env/lib/python2.7/site-packages/django/core/files/storage.pyc in save(self, name, content) 46 name = content.name 47 ---> 48 name = self.get_available_name(name) 49 name = self._save(name, content) 50

/home/jonas/workspace/mysite/env/lib/python2.7/site-packages/django/core/files/storage.pyc in get_available_name(self, name) 72 # filename doesn't exist.

 73         count = itertools.count(1)

---> 74 while self.exists(name): 75 # file_ext includes the dot.

 76             name = os.path.join(dir_name, "%s_%s%s" % (file_root, count.next(), file_ext))

/home/jonas/workspace/mysite/env/lib/python2.7/site-packages/storages/backends/s3.pyc in exists(self, name) 192 if self.entries: 193 return name in self.entries --> 194 response = self.connection._make_request('HEAD', self.bucket, name) 195 return response.status == 200 196

/home/jonas/workspace/mysite/env/lib/python2.7/site-packages/S3.pyc in _make_request(self, method, bucket, key, query_args, headers, data, metadata) 272 final_headers = merge_meta(headers, metadata); 273 # add auth header

--> 274 self._add_aws_auth_header(final_headers, method, bucket, key, query_args) 275 276 connection.request(method, path, data, final_headers)

/home/jonas/workspace/mysite/env/lib/python2.7/site-packages/S3.pyc in _add_aws_auth_header(self, headers, method, bucket, key, query_args) 298 c_string = canonical_string(method, bucket, key, query_args, headers) 299 headers['Authorization'] = \ --> 300 "AWS %s:%s" % (self.aws_access_key_id, encode(self.aws_secret_access_key, c_string)) 301 302

/home/jonas/workspace/mysite/env/lib/python2.7/site-packages/S3.pyc in encode(aws_secret_access_key, str, urlencode) 83 # access key, optionally urlencoding the result

 84 def encode(aws_secret_access_key, str, urlencode=False):

---> 85 b64_hmac = base64.encodestring(hmac.new(aws_secret_access_key, str, sha).digest()).strip() 86 if urlencode: 87 return urllib.quote_plus(b64_hmac)

/usr/lib/python2.7/hmac.pyc in new(key, msg, digestmod) 131 method. 132 """ --> 133 return HMAC(key, msg, digestmod)

/usr/lib/python2.7/hmac.pyc in init(self, key, msg, digestmod) 70 71 key = key + chr(0) * (blocksize - len(key)) ---> 72 self.outer.update(key.translate(trans_5C)) 73 self.inner.update(key.translate(trans_36)) 74 if msg is not None:

TypeError: character mapping must return integer, None or unicode

}}}

Comments (0)

  1. Log in to comment