I would like to check a file (or several) whether they really are the files that have been specified with the extension . E.g. .pdf does not contain .exe content.
I don't want a PDF file to contain executable code and only use the pdf extension. In x++ I validated for certain file types with reg ex e.g. pdf
Is there a library?
Use Case: I built an extensible control in MS D365 for finance and operations. This is a file drop zone. I have to check these files. I can either do this in my external resources (Json) or in X++ itself. Would prefer X++. I am a beginner in both languages. I have the files in X++ as two strings with the name and the base data. In java script as shown below.
$(".droparea").on("drop", function (event) {
event.preventDefault();
event.stopPropagation();
var file = event.originalEvent.dataTransfer.files;
for (let i = 0; i < file.length; i++)
{
var fileName = file[i].name;
var fileBase64 = window.btoa(file[i]);
var params = { _fileName: fileName, _fileBase64: fileBase64 };
//send files to x++ Control-Class
$dyn.callFunction(self.SetFiles, self, params);
}
});