javascript - Displaying a string representation of an image on client side using express -
im using jsftp in express
application serve string representation of image ftp connection, working fine. however, image not display when sending client:
router.get('/', (req, res, next) => { let str = '' ftp.get('/uploads/test.png', function (err, socket) { if (err) return socket.on('data', function (d) { str += d.tostring() }) socket.on('close', function (haderr) { if (haderr) { console.error('there error retrieving file.') } res.writehead(200, { 'content-type': 'image/png' }) res.end(str, 'binary') }) socket.resume() }) })
any appreciated, thanks!
you try debugmode: true
in ftp connection, listen debug events, , check if there's error during connection.
Comments
Post a Comment