You don't need the data:image/jpeg;base64, at the start of the string, that is actually not part of Base64 encoding per se but a Base64 Data URI for a web browser. Just pass the string from /9j/4AAQSkZJRgABAQAAAQABA... onwards and it will decode properly.