Have you tried sending the data in very small chunks? This might help. Also, make sure that the image is being received with the same format that is being sent. So, if you’re sending a .png image make sure that the receiver is also set to receive a .png. There are some examples that you can check here:
https://github.com/MakersTeam/Edison/tree/master/Python-Examples/Email. This example is written in Python and it is exactly what you’re trying to do, I think you’ll find this one very helpful.
Thankyou for your fast response, I have been playing with your ideas and I have found that the issue is not the sie of the chunks. It could be the encoding type from the buffer that I am using to read those chunks. I tried to change it to base64 but it does not works.
My image is captured using the v4l2camera package and converted to png through the pngjs package.
After a lot of tests I found that I can send bitmap images, i suppose that it is because they are not compressed. So I decided to convert the png or the raw file that v4l2camera returns to bmp but I have not found a good package that do this, or I have not found the way to convert those files. I found a jimp package but it has lots of errors.
Do you know how to convert raw or png files to bmp files with node.js (intel xdk)