Mercurial > public > sg101
comparison core/image_uploader.py @ 737:775e7f74096a
For #60, encode user photo filenames before logging.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 13 Dec 2013 19:59:36 -0600 |
parents | e888d627928f |
children | df2799f725d8 |
comparison
equal
deleted
inserted
replaced
736:1fe6b98f3eab | 737:775e7f74096a |
---|---|
42 | 42 |
43 A tuple is returned: (image_url, thumb_url) where thumb_url will be None if | 43 A tuple is returned: (image_url, thumb_url) where thumb_url will be None if |
44 a thumbnail was not requested. | 44 a thumbnail was not requested. |
45 """ | 45 """ |
46 | 46 |
47 logger.info('Processing image file: {}'.format(fp.name)) | 47 filename = fp.name.encode('utf-8') |
48 logger.info('Processing image file: %s', filename) | |
48 | 49 |
49 # Trying to use PIL (or Pillow) on a Django UploadedFile is often | 50 # Trying to use PIL (or Pillow) on a Django UploadedFile is often |
50 # problematic because the file is often an in-memory file if it is under | 51 # problematic because the file is often an in-memory file if it is under |
51 # a certain size. This complicates matters and many of the operations we try | 52 # a certain size. This complicates matters and many of the operations we try |
52 # to perform on it fail if this is the case. To get around these issues, | 53 # to perform on it fail if this is the case. To get around these issues, |
90 thumb_key = '{}t{}'.format(unique_key, ext) | 91 thumb_key = '{}t{}'.format(unique_key, ext) |
91 thumb_url = bucket.upload_from_string(thumb_key, | 92 thumb_url = bucket.upload_from_string(thumb_key, |
92 thumb.getvalue(), | 93 thumb.getvalue(), |
93 metadata) | 94 metadata) |
94 | 95 |
95 logger.info('Completed processing image file: {}'.format(fp.name)) | 96 logger.info('Completed processing image file: %s', filename) |
96 | 97 |
97 return (image_url, thumb_url) | 98 return (image_url, thumb_url) |