Reputation: 15786
I've got two files and I'm trying to post them to an endpoint via cURL
.
file1.csv
header1,header2
row1_value1,row1_value2
row2_value1,row2_value2
file2.csv
header1;header2
row1_value1;row1_value2
row2_value1;row2_value2
Only file1.csv
passes the validation rule mimes:csv
.
curl -F "[email protected]" -X POST http://host/api/endpoint
I've tracked down the method that causes the validation to fail. It's in Symfony
's FileinfoMimeTypeGuesser
which in turn just does
(new \finfo(\FILEINFO_MIME_TYPE, null))->file($path)
Is it possible to make finfo
consider csv's delimited by a non-standard character, such as a semicolon ;
, to be considered as a csv
file so both of my example files pass Laravel
's 'mimes:csv'
validation?
I'm unfamiliar with how finfo
works under the hood, but there is an optional $magic_database
argument that can be passed in.
Upvotes: 0
Views: 47