Maximum file size in a Smart Action field "File"

Expected behavior

I would like to be able to increase the file size limit in a File field of a Smart Action

Actual behavior

When I configure a Smart Action with a File field, I don’t see the possibility of choosing the maximum file size. Is it currently possible?

Thank you.

Hi @marc!
Welcome in the Forest community!

Do you confirm that you created a admin api microservice using Lumber CLI?
What is the current file size limit you observe by default?

Thanks for your help.

POST /forest/actions/upload-image 413 3824 - 7.539 ms
PayloadTooLargeError: request entity too large

This is the backend log when i upload a image of 1MB

I think you can configure the default limit in you app.js file.

For instance, if you want to allow 10MB, here is what you need to do:

- app.use(bodyParser.json());
+ app.use(bodyParser.json({ limit: '10mb' }));
- app.use(bodyParser.urlencoded({ extended: false }));
+ app.use(bodyParser.urlencoded({ extended: false, limit: '10mb' }));

Let me know if it helps.

4 Likes

Yes!! Thank you so much.

Hello,
When we set a limit of 10mb to the bodyParser, our file of 8.5mb gets rejected.
However when we set a limit of 12mb it gets successfully uploaded.
Did anyone faced the same issue ?

@sebpsdev There may be additional data sent to the backend. Also, files are encoded to base64: according to this thread, the size of the data is increased to 4/3 of the original. In your actual case, 8.5*4/3 ≈ 11.33. So 12mb is OK, but not 10mb.

:point_right: I would suggest setting the limit 50% higher than what you actually upload to be sure you don’t have any issue.

Let me know if it helps! :pray:

2 Likes

This might be added permanently to the FA documentation, whatever the file size (and not for large files only). For me nothing worked until I set an arbitrary size of 5mb.