I used this answer to make apex rest resource. It works perfectly for small images, but when I want to upload a bit larger image, the bottom part just gets cut.
Request went well and the image was attached, but when I preview it, I only see the top part of the image:
And when I look at the attachment details I see that this image is only 215Kb:
When I look at the same image on my machine it says that it is 1.1Mb:
So the question is:
What can be the reason of such behaviour?
As you already identified, some part of your data is lost somewhere.
I assume the Base64 encoded string gets cut somewhere because it doesn’t fit in a window, or field or editor or whatever, and then when you try to upload it, it only uploads a part (the first part) of the image. Due to the JPG format, it is still able to render the bytes that it did receive, i.e. the first part of the image.
So the ‘missing bottom part’ really is ‘the missing last part’ of the image and the cause probably is the uploaded Base64 string.