Method Illuminate\Validation\Validator::validateClamav does not exist. (Laravel 7)
VShander opened this issue · comments
VShander commented
After update to Laravel 7 I'm get this error ( Method Illuminate\Validation\Validator::validateClamav does not exist.) Everything worked fine on laravel 6! Can you guess what the problem is?
Krishnaprasad MG commented
@VShander I just tried the library with a fresh Laravel 7 installation and i see it works expected (see below), So i guess this has something to do with your application instead.
- Create a new project with Laravel 7
~/ composer create-project --prefer-dist laravel/laravel blog 2255ms < Wed Mar 11 10:23:24 2020
Creating a "laravel/laravel" project at "./blog"
Installing laravel/laravel (v7.0.0)
- Installing laravel/laravel (v7.0.0): Downloading (100%)
Created project in /Users/user1/dev/blog
....
- Install clamav validator (https://github.com/sunspikes/clamav-validator#installation)
~/blog composer require sunspikes/clamav-validator
Using version ^2.2 for sunspikes/clamav-validator
./composer.json has been updated
....
- Create a new file upload route in
routes/api.php
Route::post('/upload', function (Request $request) {
try {
$validatedData = $request->validate(['file' => 'clamav']);
} catch (\Illuminate\Validation\ValidationException $e) {
return $e->errors();
}
/** @var UploadedFile $file */
$file = $validatedData['file'];
return var_export($file->isValid(), true);
});
- Upload an infected file (https://en.wikipedia.org/wiki/EICAR_test_file)
~/d/blog http -f POST 'http://127.0.0.1:8000/api/upload' file@virus.txt
HTTP/1.1 200 OK
{
"file": [
"file contains virus."
]
}
- Upload a clean file
~/d/blog http -f POST 'http://127.0.0.1:8000/api/upload' file@clean.txt
HTTP/1.1 200 OK
true