Based on your comment, it sounds like the the original file (input
) contains the actual bytes of the image. But for some reason, you're then reading those bytes in as if they are the Base 64 encoded ASCII representation of the image. Clearly they aren't, so why are you doing this? If you skip the Base64.decodeBase64
step, I'm guessing things will work as expected.
Of course, in that case what you're doing is simply copying the bytes of input
to f
, which is simpler and more efficient to do as:
Files.copy(input, f);
Or if you have no need to leave the temporary file where it is, moving the file is even better:
Files.move(input, f);