インターネットから画像をダウンロードしています(Boxから)、body.length
とヘッダーcontent-length
が違ってきています。Nodejs異なるコンテンツの長さ
応答ヘッダーcontent-length
は75739
と同じです。 ただし、body.length
はと同じです。
request(url).pipe(fs.createWriteStream('image.jpg'))
を実行すると画像が75739になり、正常に開きます。
fs.writeFileSync('image.jpg', body)
を実行した場合、イメージは137515になり、正しく表示されません。
自分でテストすることができますので、私もこの主旨をした:https://gist.github.com/Daymannovaes/54663e0718f0ded40285d0666f937179
エンコーディングが問題であるならば、私は知りませんが、私はすべてのエンコードとバイト長を取得しようとしましたし、それらのどれも修正しませんでしたサイズ:事前に
length of the body (ascii) 72818 length of the body (utf8) 137515 length of the body (utf16le) 5636 length of the body (ucs2) 145636 length of the body (base64) 54613 length of the body (latin1) 72818 length of the body (binary) 72818 length of the body (hex) 36409
ありがとう!