I try to upload an image to strapi as part of an article. I manage to upload the image itself to a folder in strapi but when I try to use it I get an empty file:
This is the uploading image code, that works:
def upload_image(image_name: str, path_to_image: str):
api_url = "https://strapi-app-erf4d.ondigitalocean.app/api/upload"
files = {"files": (image_name, open(path_to_image, "rb"), "image")}
headers = {
"Authorization": f"Bearer {config.strapi_access_token()}",
}
response = requests.post(api_url, files=files, headers=headers).json()
image_id = response[0]["id"]
return image_id
Then I try to do a request with that image:
{
"__component": "shared.media",
"file": {
"url": f"/uploads/{image_name}.jpg",
},
}
And I get:
How should I define the image? which URL should I use?
Thank you!