Open apuatcfbd opened 3 months ago
I needed this as well but realised that it is a very difficult problem. I would suggest first looking at other heuristics such as file extension. Outside of that the only really reliable way to check the file is a library such as magika
from Google. Currently only available for Python, Rust, and Node, but is actively being worked on for Go.
CSV & JSON are two of the most common file formats when we work with web applications. Unfortunately, the lib doesn't support that. Support for CSV is very much needed.