How to serializer a file object while using json.dumps ?
I 'm using pytest for testing file upload in django and I 've this function
def test_file_upload(self):
# file_content is a bytest object
request = client.patch(
"/fake-url/",
json.dumps({"file" : file_content}),
content_type="application/json",
)
I 've tried to set the file_content
as a bytes object but I 'm getting this error TypeError: Object of type bytes is not JSON serializable
I need to send the whole file to my endpoint as json serialized