in pulseapi/profiles/views/profiles.py [0:0]
def put(self, request, *args, **kwargs):
"""
If there is a thumbnail, and it was sent as part of an
application/json payload, then we need to unpack a thumbnail
object payload and convert it to a Python ContentFile payload
instead. We use a try/catch because the optional nature means
we need to check using "if hasattr(request.data,'thumbnail'):"
as we as "if request.data['thumbnail']" and these are pretty
much mutually exclusive patterns. A try/pass make far more sense.
"""
payload = request.data
thumbnail = payload.get('thumbnail')
if thumbnail:
name = thumbnail.get('name')
encdata = thumbnail.get('base64')
if name and encdata:
request.data['thumbnail'] = ContentFile(
base64.b64decode(encdata),
name=name,
)
return super(UserProfileAPIView, self).put(request, *args, **kwargs)