Rhymen / go-whatsapp

WhatsApp Web API
MIT License
2.07k stars 493 forks source link

Image: file length does not match #478

Open emauro opened 3 years ago

emauro commented 3 years ago

In my app this error message appeared when a group of four images were received. The app could only download the first one. The remaining three resulted in the error message. That's odd. What might be happened? Could the error be due the images appear grouped in the device? I tried to reproduce the problem to no avail.

I suggest adding to the error message the received size and the expected one.

SchulteMK commented 3 years ago

I changed the error message, to be more specific. Can you please retry and give us some feedback on the problem?

rhsobr commented 3 years ago

It looks like that even the official API has this issue. I know that exists an opened ticket with same subject on their hands.

Valdenirmezadri commented 3 years ago

Hello, since yesterday I have faced this same problem

Valdenirmezadri commented 3 years ago

I changed the library to ignore the length, the image arrives and is correct, I'll leave it at that for now as I don't know if this will be corrected, I'll post only the link that I changed.

https://github.com/Valdenirmezadri/go-whatsapp/commit/94fdcb098801ac867c22b64470f2c721ca6f936e

then on my app:

func (h *WhatsAppAPI) imageDownload(message whatsapp.ImageMessage) ([]byte, error) { file, err := message.Download() if err != nil { if err == whatsapp.ErrMediaFileLengthDoesNotMatch { return file, nil } ...

fredjsf commented 3 years ago

I have same problem.

emauro commented 3 years ago

It seems to happen very sporadically. Today it happened for just one device for some images sent just by one number.

emauro commented 3 years ago

I changed the library to ignore the length, the image arrives and is correct, I'll leave it at that for now as I don't know if this will be corrected, I'll post only the link that I changed.

It solves the problem and indeed the image is correct. But I am not sure if the image will be always correct. I am pretty sure that just one byte is being added somewhere (not by go-whatsapp).

Valdenirmezadri commented 3 years ago

It seems to happen very sporadically. Today it happened for just one device for some images sent just by one number.

yes, it is not all images that occur the problem, I realized that it occurs more when it is an image forwarded from another whatsapp. I have an image with this problem, I can send you if you want to test

Valdenirmezadri commented 3 years ago

I changed the library to ignore the length, the image arrives and is correct, I'll leave it at that for now as I don't know if this will be corrected, I'll post only the link that I changed.

It solves the problem and indeed the image is correct. But I am not sure if the image will be always correct. I am pretty sure that just one byte is being added somewhere (not by go-whatsapp).

What i can tell you here, is that all the images that occurred this error were photos taken by the cell phone camera and forwarded to WhatsApp