Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "422 Unprocessable Content" while uploading file #54

Closed
azamalvi opened this issue Jan 9, 2023 · 7 comments
Closed

Error "422 Unprocessable Content" while uploading file #54

azamalvi opened this issue Jan 9, 2023 · 7 comments

Comments

@azamalvi
Copy link

azamalvi commented Jan 9, 2023

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
Copy link
Owner

RTippin commented Jan 9, 2023

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
Copy link
Author

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
Copy link
Owner

RTippin commented Jan 10, 2023

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
Copy link
Author

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

@RTippin
Copy link
Owner

RTippin commented Jan 10, 2023

I would say to check your config/env for the audio size:

'size_limit' => env('MESSENGER_MESSAGE_AUDIO_SIZE_LIMIT', 10240),

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
Copy link
Author

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
Copy link
Owner

RTippin commented Jan 10, 2023

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:

private function generateAudioRule(): void
{
$limit = Messenger::getMessageAudioSizeLimit();
$mimes = Messenger::getMessageAudioMimeTypes();
$this->generatedRuleset['audio'] = ['required', "max:$limit", 'file', "mimes:$mimes"];
}

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

@RTippin RTippin closed this as completed Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants