0
function media(req,res){
console.log(req.query.image);
var collectionName = 'imageTable';
var selector = MongoHelper.idSelector(req.query.image);
MongoHelper.findOne(selector, collectionName, function(err, image) {
console.log(image.picture);
var url_parts = url.parse(image.picture);
var options = {host: url_parts.hostname, path: url_parts.pathname};
http.get(options).on('response', function (response) {
var body = '';
var i = 0;
response.on('data', function (chunk) {
i++;
body += chunk;
console.log('BODY Part: ' + i);
});
response.on('end', function() {
console.log('Finished');
res.writeHead(200,{'Content-Type':'image/JPEG'});
res.write(body);
res.end();
});
});
});
}
다른 서버에서 이미지를 가져 오는 중입니다. 나는 그 이미지의 URL을 가지고있다. 그리고 나는 그 반응을 쓰고있다. 하지만 여기서 응답 이미지가 손상됩니다. 응답으로 jpeg 이미지를 작성하는 방법에 대한 아이디어?다른 서버에서 이미지를 읽고 응답을 작성하려고합니다.