I am currently working on a Spring-Boot application which is able to receive files' data encoded in Base64, and send them to a recipient user.
I upload the following data:
{
"fileName":"excelfile",
"fileExtension":"xlsx",
"fileData":"<base64 string>"
}
I want to validate the uploaded data, so I need to make sure if the base64 string actually decodes into an xlsx Excel Spreadsheet file. Until now I tried my best with URLConnection and Apache Tika, however Tika could only identify through the file name whether the application/vnd.openxmlformats-officedocument.xxxx is actually an Excel Spreadsheet document or not.
With so much effort a user could simply upload a base64 encoded Word document with an extension of xlsx, confusing the application.
For my application it would be enough to extract the file extension form the base64 sting. Are there utility libraries for such tasks? I do know that the public tool Base64.Guru has it's way to determine the openxmlformats-officedocument's actual subtype and extension, so I don't see it an impossible task.