How do I start a process via REST with a base64 File variable correctly?

I am trying to start a process via REST with several variables. All other variables work fine, except for my image. This is my variable definition in JavaScript

"imageBase64": {
    value: imageAsBase64String,
    type: "File",
    valueInfo: {
        filename: "image.jpg",
        mimetype: "image/jpeg",
        encoding: "UTF-8"

Here, my value looks like data:image/jpeg;base64,/9j/4AAQSkZJRgA.... This is how I try to read the variable in a Java Worker

FileValue image = this.externalTask.getVariableTyped("imageBase64");
InputStream inputStream = image.getValue();
byte[] byteArray = new byte[inputStream.available()];;
File targetFile = new File("/home/joel/projects/camunda-worker/targetFile.jpg");
OutputStream outStream = new FileOutputStream(targetFile);

At this point the image writte to disk seems to be garbage, I can’t really even paste it here. I know I am doing something wrong, but I can’t figure out how to do it correctly - any help is very appreciated!

It would appear that I am am a fool. Upon further inspection, my “base64” data was garbage as in it included the part in the beginning data:image/jpeg;base64, - that broke everything.

Removed that bit and it worked just fine.