I'm trying to send image / files to Strapi collection type with Python Requests?
I have a collection type called log which has a single media (and two text fields). I don't know how to create a new log with an image.
I'm just mashing code, but this is what I have at the moment (I'm trying to make the image streamable hoping that would work):
import requests
from utils.networking import LOCAL, PORT
import io
import numpy as np
import matplotlib.pyplot as plt
# I converted the image from numpy array to png
buf = io.BytesIO()
plt.imsave(buf, cvimage, format='png')
image = buf.getvalue()
payload = {
"Type": 'info'
"Message": 'Testing',
}
req = requests.post(f'http://localhost:1337/logs', json=payload, data=image)
I've tried using requests.post's files parameter instead of data, but I couldn't get that working. Also, I've tried posting to /upload as well, but failed.