Image not working?
Disane87 opened this issue ยท 3 comments
HI, thank you for this great project! Currently I'm using your api for my project. Now I wanto to get the image of a product, but this isnt working:
app.get('/image/:imageid.:extension', cors(corsOptions), async (req, res) => {
const imageID = req.params.imageid;
const extension = req.params.extension;
const image = await picnicClient.getImage(imageID, ImageSizes.LARGE);
// const base64Image = new Buffer.from(image.toString('binary'), 'base64')
// res.writeHead(200, {
// 'Content-Type': `image/${extension}`,
// 'Content-Length': image.length
// });
res.set('Content-Type', `image/${extension}`);
res.set('Content-Length', image.length);
res.set('Image-ID', `image/${extension}`);
return res.end(image);
})
Am I doing it wrong?
Correct, the api sends a request with some incorrect headers. This needs to be fixed, which I will do soon, thanks for reporting. ๐
If you want a temporary fix you can send a request like this: 'https://storefront-prod.nl.picnicinternational.com/static/images/IMAGE_ID/SIZE.png'
.
Example: 'https://storefront-prod.nl.picnicinternational.com/static/images/8560e1f1c2d2811dfefbbb2342ef0d95250533f2131416aca459bde35d73e901/medium.png'
This is basically what the api does as well.
Thank you for investigation! Actually I load them by the url manually like you proposed :)
Kind regards from Germany ๐ฉ๐ช to my beloved Dutchies
Got distracted, but fixed it just now in v1.4.2. ๐