Send a file from glitch project to my bot doesn't work

So in my server:

    const blob = __dirname + '/blobs/' + name + '.png';
    fs.readFile(blob, function (err, content) {
        if (err) {
            res.writeHead(400, {'Content-type':'text/html'})
            console.log(err);
            res.end("No such image");    
        } else {
            res.writeHead(200,{'Content-type':'image/png'});
            res.end(content);
        }
    });

And in my bot:

request("https://rsg-images-api.glitch.me/blob/" + args[0], function (err, res, body) {
    if (err) return message.channel.send(err)
    console.log(res.body)
})

res.body gives https://pastebin.com/R2puLvsZ as output, but it should be the image. ( https://www.codexpedia.com/node-js/node-js-http-server-respond-with-an-image-by-request/ )

res.sendFile in server also won’t fix it but also send that number image thingy.

Is this because of glitch? or is there a problem with me code?
I also tried

.use("/blob", express.static(__dirname + '/blobs/'))

and that output also gives that pastebin

Could you DM me an invite to the project.

sure, i have send it to you.

@RobinSchapendonkGame it looks like the code you were talking about it a note.

Fixed. It should work now.

1 Like