I need to load an image object from different object storage codes and send it to the user through the Django Rest Framework.
I have something like this:
if request.method == 'GET':
conn = swiftclient.client.Connection(**credentials)
container, file = 'container_name', 'object_name'
_, data = conn.get_object(container, file)
return Response(data, content_type="image/png")
data the variable contains the type of bytes.
During testing, I get an error message:
'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte
What could be the solution to this problem?
source
share