0

I am writing an web api that accepts file as base64 string and converts it to two dimentional array. One of the requirements is to verify that the file is of type that is excepted and this should be done by validating the file base64 string. For example this is the validation for PDF. How to do it for xlsx & csv?

if (file.Take(7).SequenceEqual(PDF))
{
    mime = "application/pdf";
}
Vasil Indzhev
  • 635
  • 1
  • 7
  • 17
  • Where did you get the variable `PDF` from? I think you are looking for an answer like [this one](http://stackoverflow.com/a/29213015/5095502), where I assume the only difference for you is that someone took `byte`'s that represent a file and turned them into `base64string`, if I understand you correctly. Maybe you can turn it back into `byte[]` then follow that answer. Note that that method will only tell you to if a file is a text file, you have to further interpret it to know if that text file follow CSV standards or not. – Quantic Nov 17 '16 at 15:43
  • try with urlmon.dll http://stackoverflow.com/a/58570/3762855 but for csv you should use its structure to validate it – Ciro Corvino Nov 17 '16 at 15:51

0 Answers0