[boobmsg] Use url suffix to save photos with their extension

This commit is contained in:
Roger Philibert 2012-03-29 23:07:28 +02:00 committed by Laurent Defert
commit b0f1035ae8

View file

@ -455,7 +455,11 @@ class Boobmsg(ReplApplication):
# Write photo to temporary files
tmp_files = []
for photo in contact.photos.values():
f = NamedTemporaryFile(suffix='.jpg')
suffix = '.jpg'
if '.' in photo.url.split('/')[-1]:
suffix = '.%s' % photo.url.split('/')[-1].split('.')[-1]
f = NamedTemporaryFile(suffix=suffix)
photo = backend.fillobj(photo, 'data')
f.write(photo.data)
tmp_files.append(f)