Closed connecteev closed 1 year ago
You can use https://github.com/laravel/framework/blob/10.x/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php Illuminate\Foundation\Http\Middleware\ValidatePostSize
to cover this use case.
Can you share an example of how this would work with Nova? Are you referring to a rule like this?
->rules('required', 'file', 'max:2048000')
Also, what about Case 2, which looks like a bug?
You can read about middleware using https://laravel.com/docs/10.x/middleware#main-content
Also, required()
isn't the same as rules('required')
, this has been explicitly mentioned in the documentation.
Description:
Related to the issue described here https://github.com/laravel/nova-issues/issues/5880 Although the original issue (of failing file uploads) was resolved due to max allowable file sizes by PHP / Nginx, Nova needs to handle errors more gracefully.
When file uploads dont work (say, because the max PHP file size limit and/or the max file size specified by Nginx or Herd is exceeded), Nova doesn't seem to know of / handle errors very gracefully. Sometimes, it thinks that the file was uploaded and the resource was created, even though neither of those happened. At other times, it displays a server error.
Screenshots of all scenarios can be found below.
Detailed steps to reproduce the issue on a fresh Nova installation:
Create a CourseVideo Nova resource with the following
File
field type to accept file / video uploadscourse_videos migration file:
Set a low value for
upload_max_filesize
andpost_max_size
in your php.ini file: /Users/connecteev/Library/Application Support/Herd/config/php/{74,80,81,82,83}/php.ini: Added to all php.ini files:Set a low value for
client_max_body_size
in your nginx.conf and/or herd.conf file:/Users/connecteev/Library/Application Support/Herd/config/nginx/nginx.conf:
client_max_body_size 1M;
/Users/connecteev/Library/Application Support/Herd/config/nginx/herd.conf:
client_max_body_size 1M;
Test with files > 1MB at https://file-examples.com/index.php/sample-video-files/sample-mov-files-download/ and https://file-examples.com/index.php/sample-video-files/sample-mp4-files/
Now, go to the Nova admin and try to upload a new video, in my case: /admin/resources/course-videos/new On submitting the form (in my case pressing the "Create Course Video" button), you either see:
Case 1 (File upload works successfully):
Case 2 (File upload fails, but Nova thinks it worked):
Case 3 (File upload fails, Nova gives an error message):
In both case 2 and 3, this is what you see a similar error in the laravel.log server logs: