You have to use the base64 string representation of the image. Please refer to the below link to check how you can use FileReader to convert the image to a data URL.
stackoverflow.com/questions/6150289/…
Then you have to convert the base64image to a physical image using your API code.