Uploading Images into Cloudflare using node.js

I am trying to upload an image into Cloudflare using node.js; however, I keep getting this error
errors: [
  {
    code: 5455,
    message: 'Uploaded image must have image/jpeg, image/png, image/webp, image/gif or image/svg+xml content-type'
  }
],


My current function for the upload is
async function uploadImageToCloudFlare(path)
{
    const fileData = fs.readFileSync("src/uploads/dog.jpeg")

    const API_KEY = process.env.CLOUDFLARE_API_KEY
    const ACCOUNT_ID = process.env.CLOUDFLARE_ACCOUNT_ID

    const url = `https://api.cloudflare.com/client/v4/accounts/${ACCOUNT_ID}/images/v1`;

    const headers = {
        'Authorization': `Bearer ${API_KEY}`,
        'Content-Type': 'multipart/form-data',
    };

    const formData = new FormData();
    formData.append('file', fileData);

    const response = await axios.post(url, formData, {headers})
    return response;
}


The directory the images are in is in the picture.

I don't think it's any trouble with retrieving the image.

I have tried making content-type the same content type as file request
I have tried the sme thing on fetch since I heard there were some inconsistencies with axios
I have also checked the properties of the file manually and it is a jpeg file
image.png
Was this page helpful?