Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect downloaded data #10

Open
luyi985 opened this issue Apr 6, 2018 · 1 comment
Open

Incorrect downloaded data #10

luyi985 opened this issue Apr 6, 2018 · 1 comment

Comments

@luyi985
Copy link

luyi985 commented Apr 6, 2018

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

@luyi985 luyi985 changed the title In correct downloaded data Incorrect downloaded data Apr 6, 2018
@FdezRomero
Copy link
Owner

FdezRomero commented May 10, 2018

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants