I am trying to fetch images that I have uploaded to my CDN. I used canvas.toDataURL to convert my images to PNGs before upload.
I get the following error when I try to fetch the images: Error: cURL error 61: Unrecognized content encoding type. libcurl understands deflate, gzip, br content encodings
So first I created this image using FabricJS: Then I am exporting it as a PNG using:
const dataURL = canvas.toDataURL({
width: canvas.width,
height: canvas.height,
left: 0,
top: 0,
format: 'png'
})
Then I am uploading it to my S3 CDN using:
async function uploadPNG(dataURL, filePath) {
const buf = Buffer.from(dataURL.replace(/^data:image\/\w+;base64,/, ""),'base64')
const uploadParams = {
Bucket: bucketName,
ContentType: 'image/png',
ContentEncoding: 'base64',
Body: buf,
Key: filePath
}
return await s3.upload(uploadParams).promise()
}
Then I am trying to upload that image (which is now in the S3 CDN) to a WooCommerce site using their API. https://s3.eu-central-1.amazonaws.com/cdn.blankt.com/product/s/AY6AJSHMXnf2ReCZOu.png
Here is part of that API request:
{
"name": "AY6AJSHMXnf2ReCZOu",
"type": "variable",
"regular_price": "9.90",
"sku": "AY6AJSHMXnf2ReCZOu",
...
],
"images": [
{
"src": "https://s3.eu-central-1.amazonaws.com/cdn.blankt.com/product/s/AY6AJSHMXnf2ReCZOu.png"
}
],
"attributes" : [
{
"name" : "Size",
"variation" : true,
"visible" : true,
"options" : [ "A3", "A4", "A5" ]
}
]
}
And this is the response that I get: 
This problem seem to only appear when I try to upload the image using the API, if I download and upload the image manually to WooCommerce, there are no problems.
from "Unrecognized content encoding type" error when uploading an image
No comments:
Post a Comment