Estoy usando la API de imágenes para cargar un montón de imágenes en Cloudflare. Pero tengo problemas con los svgs... ¿alguien sabe si Cloudflare los admite? No estoy encontrando ningún documento para eso. ¡Gracias!
Recibo este error al ejecutar el código. 'ERROR 9422: Error de decodificación: no se pudo decodificar la imagen: la imagen cargada debe tener el tipo de contenido imagen/jpeg o imagen/png\n'
Mi código:
let imageUrl = ""; // We get the datoCMS image upload id and fetch the url, then we post it in cloudfare const image = await datoManagementPrimaryEnvironment.upload.find(uploadId); const fileName = title ? title : image.basename ? image.basename : "image"; const response = await axios.get(image.url, { responseType: "stream" }); const form = new FormData(); // Pass image stream from response directly to form form.append("file", response.data, `${fileName}`); try { const postRes = await axios .post( `https://api.cloudflare.com/client/v4/accounts/${cloudfareId}/images/v1`, form, { headers: { ...form.getHeaders(), Authorization: `Bearer ${cloudfareApiKey}`, }, } ) .then((fetchRes) => { return (imageUrl = fetchRes.data.result.variants[0]); }); return postRes; } catch (error) { console.error("Error while uploading to cloudflare", error); } finally { return imageUrl; }