Chunked media upload API fails to upload Images

I am using an external library recommended by Twitter i.e twitter4J
I am using chunked media upload API to upload media

uploadMediaChuked method definition | twitter4J
It is working fine in case of videos, but when I try to upload images I am getting the following error.

Failed to finalize the chuncked upload.
Moreover, it is mentioned in the Java Docs of the library that, This API should be used for videos. But I think Twitter supports image upload with chunked API too according to the documentation. Kindly anyone help me out there. Thank you