chungchunwang / Budibase-File-Upload

Upload files in your Budibase app!
MIT License
22 stars 11 forks source link

upload error ! payload too large #2

Closed mincheol-jeong closed 1 year ago

mincheol-jeong commented 1 year ago

Hi I'm currently using the Budibase https://github.com/chungchunwang/Budibase-File-Upload plugin and I keep getting an error that the payload is too large. Even though mysql converts to longtext and max_allowed_packet is set to 1GB, even inserting a 4MB file results in a payload too large error. Is there a way?

chungchunwang commented 1 year ago

Hi! Did you set your max_allowed_packet for MySQL via the config file and then restart the server? See this Stack Overflow answer. If you did not restart the server then the changes will not register.

If you set the variable via a query (such as like this SET GLOBAL max_allowed_packet=1073741824) I would recommend you try setting it using the config file instead; I tried using that query when setting up the plugin for my own system, but it did not seem to work as intended. My best guess for why this is the case is that these variable changes only register for new connections, but Budibase is constantly connected with the SQL server, so therefore the changes do not apply to it.

Additionally, if you are using nginx or some other web server as a reverse proxy for Budibase you will need to limit the maximum files size for it as well. In nginx this would be to set the client_max_body_size to something larger, as shown in this Stack Overflow response.

mincheol-jeong commented 1 year ago

Even if you try, the result is the same. Even if max is set in the sql configuration file, restarted, and max is set, the same payload too large error appears.

chungchunwang commented 1 year ago

Hi! Sorry to hear that you still have this problem. Unfortunately, I am not able to come up with any possible solutions based on what you have described. Considering the error message, this is not an issue with the plugin, but with either Budibase or MySQL blocking large packets. Maybe you can try to get help on relevant forums for those projects?

I will close this issue for now. If you have more details that could help with resolving this, feel free to open this issue again.

FlaminWrap commented 1 year ago

I am having the same issue. I have added the mysql max_allowed_packet to the config and ran the query and set the client_max_body_size to 0 in my nginx reverse proxy and the bbproxy container and neither have made a difference.

This is what the bbproxy error log shows: 2023/02/09 15:11:41 [warn] 26#26: *43 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000001, client: 172.18.0.1, server: _, request: "POST /api/datasource_plus_6009a27a119e48d8878bfd2a5b6eec86__TableName/rows HTTP/1.0", host: "server.company.com", referrer: "https://server.company.com/app/appname" Could this be a problem with budibase?

FlaminWrap commented 1 year ago

I think this might be a problem with the bbapps container. I have raised a discussion in the main budibase repo here:

https://github.com/Budibase/budibase/discussions/9630

chungchunwang commented 1 year ago

Hi @FlaminWrap! I'll look into this more over the weekend, perhaps something has changed with a new Budibase update.

FlaminWrap commented 1 year ago

I have found the issue.

There are limits here: /packages/server/src/app.ts If you change jsonLimit to something bigger (e.g. 1000mb) you will not longer get the 413 error.

jsonLimit.webm

The question now is how to deploy this in production and if there could be a docker env set in budibase?

mike12345567 commented 1 year ago

I've created a PR which should allow fixing this issue, using the HTTP_MB_LIMIT environment variable which will soon be available on the app service. This can be set to any number, for example HTTP_MB_LIMIT=1000 will essentially update the form, json and text limits to 1000mb.

PR: https://github.com/Budibase/budibase/pull/9695

FlaminWrap commented 1 year ago

Thank you Mike, much appreciated.

chungchunwang commented 1 year ago

@mike12345567 @FlaminWrap Thank you both! I have updated the README instructions to reflect this #3.