'Python minio client download file using requests instead of urlopen

I'm trying to download a file using requests then put it in minio. This is my snippet:

...
resp = session.get(url, stream=True)
file_obj = io.BytesIO(resp.content)
client_minio.put_object(bucket, obj_id, file_obj, length=-1,
                                part_size=MINIO_PART_SIZE,
                                content_type=content_type)

But I get this message error:

line 66, in <listcomp>
    _MULTI_SPACE_REGEX.sub(" ", value) for value in values
TypeError: expected string or bytes-like object


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source