I've been struggling too much with this simple problem ... I'm trying the get a picture from an url to post it to a discord webhook.
request.get(options, (res, err, base64Picture)=>{
}).pipe(fs.createWriteStream(filename)).on('close', ()=>{
upload(fs.readFileSync('./' + filename))
});
This function works as intended but create a useless tmp file. I want to get the base64 string and convert it to a file format, so I try do do that:
request.get(options, (res, err, base64Picture)=>{
upload(Buffer.from(base64Picture, 'base64'), filename);
})
This one doesn't work at all. I tried to log both buffers and they are indeed different. That's what I don't get. I don't have much experience from nodejs so that might be something simple, but I have a lot of trouble not knowing the data type ...
Hopefully someone might have an answer for me.