Sending PNG from Python to Convex DB
Hi, so I am trying upload a .png image to the Convex Database. My code is sort of working, but the image that is uploaded is not readable when I download it. This is my current code:
from convex import ConvexClient
import requests
client = ConvexClient('')
send_image_url = client.mutation("groups:generateUploadUrl")
headers = {'Content-Type': 'image/png'}
files = {'body': open('TodayImg.png', 'rb')}
result = requests.post(send_image_url, files=files, headers=headers)
storage_id = result.json()['storageId']
client.mutation("groups:sendImage", dict( storageId=storage_id ))
(The image I am getting when I downloaded it off of Convex is attatched)
1 Reply
You should send the file contents directly in the body, using
data=
instead of files=
in the requests.post