Incorrect downloaded data
luyi985 opened this issue · comments
Hi mate
I find this line in your code seems not correct
https://github.com/FdezRomero/request-image-size/blob/master/index.js#L65
If it does return the buffer size(how many bytes) of the img, maybe we should set size.downloaded = Buffer.byteLength(buffer, ''utf8'')
Ref
https://nodejs.org/api/buffer.html#buffer_class_method_buffer_bytelength_string_encoding
Hi @luyi985, sorry for the late reply.
I don't see why buffer.length
is incorrect. The image data coming from the response is already a buffer, so I don't see the need to use Buffer.byteLength()
here, which seems to be intended for strings anyway. Plus images are binary, so specifying a utf8
encoding would be wrong.
If you think that the downloaded bytes number is incorrect, please provide an example that I can use to reproduce the error.
Thanks!