Upload a image to strapi

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!

Do you have upload enabled in the permissions settings to allow upload?

Here is my code example, it is in javascript. But based on what you have it look simillar to mine.

import { cookies } from 'next/headers'

export async function POST(request: Request): Promise<Response> {
  const url = `${process.env.STRAPI_URL}/api/upload`;

  const cookieStore = cookies();
  const authToken = cookieStore.get('jwt')?.value;

  if (!authToken) {
    return new Response(JSON.stringify({ error: "No JWT", ok: false }), { status: 401 });
  }

  const formData = await request.formData();
  const file: File | null = formData.get('image') as unknown as File;

  if (!file) {
    return new Response(JSON.stringify({ error: "No file", ok: false }), { status: 400 });
  }

  const newFormData = new FormData();
  newFormData.append('files', file, file.name);
  
  const response = await fetch(url, {
    method: "POST",
    headers: { Authorization: `Bearer ${authToken}` },
    body: newFormData,
  });

  const data = await response.json();
  return Response.json({ data: data[0], ok: true })
}