주어진 URL의 노드 요청 라이브러리를 사용하여 이미지를 요청하면로드 된 이미지가 완료되지 않습니다. 로드 된 이미지를 저장 한 후에는 https://ibb.co/i5xVAR노드 요청 요청이 완료되지 않았습니다.
과 같이 보입니다. 그러나 요청은 오류없이 완료되고 상태 코드 200이됩니다. 내게는 ssl 연결이 닫힌 것 같습니다. 브라우저 나 컬 같은 다른 도구는 이미지를 완벽하게 전송합니다.
const request = require('request');
const r1 = request({
url: 'https://open.hpi.de/files/f1d16619-9813-4d59-96b3-d84908929b23',
encoding: 'binary'
}, (err, response, body) => {
if (err) {
console.log(err);
return;
}
// complete file should be loaded
// content and body length should match
// read ECONNRESET should not be thrown
console.log('body length', body.length);
console.log('response content length', response.headers['content-length']);
});
당신이 시도 할 수 있습니다 :'''요청 (URL) .pipe (fs.createWriteStream (파일 이름)) .on ('close', callback);''' –
모든 데이터가 한번에 반환되는 것은 아니기 때문에 : https://stackoverflow.com/a/12751657/5115872 – wrangler
파일 시스템으로 연결하는 것은 괜찮지 만 버퍼로 응답해야합니다. 마지막으로 스트림이 아닙니다. – user3498131