RTippin / messenger

Laravel messenger. A full messenger suite for your new / existing laravel app! Private and group threads between multiple models, with real-time messaging, reactions, attachments, calling, chat bots, and more!
https://tippindev.com
MIT License
412 stars 79 forks source link

Error "422 Unprocessable Content" while uploading file #54

Closed azamalvi closed 1 year ago

azamalvi commented 1 year ago

I'm uploading a 2MB mp3 file and it gives me an error "422 Unprocessable Content" if file size is less then 2mb then it works fine. Limit on my Nginx server is 20MB.

RTippin commented 1 year ago

Can you please relay the exact message the API returns? 422 isn't anything to go off of alone, need the context from the message to know why your upload didn't pass validation.

azamalvi commented 1 year ago

Can you please relay the exact message the API returns? 422 isn't anything to go off of alone, need the context from the message to know why your upload didn't pass validation.

image

Status Code: 422 Unprocessable Content

RTippin commented 1 year ago

You mentioned you adjusted your Nginx conf to allow 20mb, but did you also update your php.ini's post_max_size and upload_max_filesize ?

azamalvi commented 1 year ago

Yes the values are ok because I can upload more then 3mb of images as well. Only issue is with the Audio file

RTippin commented 1 year ago

I would say to check your config/env for the audio size: https://github.com/RTippin/messenger/blob/92cca2804e74b79319be6177083c728ca0244038/config/messenger.php#L148

But the error you are getting is not a validation error from a file being too big. It's beyond my package/framework and something to do with your server/environment itself. May want to check your server/nginx logs.

azamalvi commented 1 year ago

Config is default.

'message_audio' => [ 'upload' => env('MESSENGER_MESSAGE_AUDIO_UPLOAD', true), 'size_limit' => env('MESSENGER_MESSAGE_AUDIO_SIZE_LIMIT', 10240), 'mime_types' => env('MESSENGER_MESSAGE_AUDIO_MIME_TYPES', 'aac,mp3,oga,ogg,wav,weba,webm'), ],

I have also checked the logs and did not find any errors. Can you please try it on your local with audio file only. It should be more then 2mb. Thanks

RTippin commented 1 year ago

I have no issues uploading a 5mb audio file myself, and as I said, the error you are getting from the failed validation is not an issue with my package. I use laravels file validations here: https://github.com/RTippin/messenger/blob/92cca2804e74b79319be6177083c728ca0244038/src/Http/Request/BaseMessageRequest.php#L123-L129

Sounds to me like your audio file is corrupt or something in your environments that is not clear to me.