Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

211
Views
Having trouble when trying to upload an svg image to Cloudfare with axios

I'm having issues with svg files while running this code. The pngs and jpgs files are uploading to Cloudfare correctly, but when an svg file appears, it returns this error:

ERROR 9422: Decode error: image failed to be decoded: Uploaded image must have image/jpeg or image/png content type\n

Does anybody knows what I'm doing wrong? thanks

export default async (req: NextApiRequest, res: NextApiResponse) => {
  const response = await axios.get(
    "https://www.datocms-assets.com/45562/test-image.png",
    { responseType: "stream" }
  );

  const form = new FormData();
  form.append("image", response.data, "test.png");

  try {
    const postRes = await axios.post(
      `https://api.cloudflare.com/client/v4/accounts/my-id/images/v1`,
      form,
      {
        headers: {
          ...form.getHeaders(),
          Authorization: `Bearer my-api-key`,
        },
      }
    );
    console.info("response", postRes);
  } catch (error) {
    console.error("Error while uploading to cloudflare", error);
  }
};
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!