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

Include upload maxFileSize and maxRequestSize. #492

Merged
merged 1 commit into from
Sep 12, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/en/guide/theWebLayer/controllers/uploadingFiles.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,33 @@ class Image {
String myFile
}
{code}

h4. Increase Upload Max File Size

Grails default size for file uploads is 128000 (~128KB). When this limit is exceeded you'll see the following exception:

{code:java}
org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException
{code}

You can configure the limit in your @application.yml@ as follows:

{code:yml}
grails:
controllers:
upload:
maxFileSize: 2000000
maxRequestSize: 2000000
{code}

@maxFileSize@ = The maximum size allowed for uploaded files.

@maxRequestSize@ = The maximum size allowed for multipart/form-data requests.

You should keep in mind [OWASP recommendations - Unrestricted File Upload|https://www.owasp.org/index.php/Unrestricted_File_Upload]

{note}
Limit the file size to a maximum value in order to prevent denial of service attacks.
{note}

These limits exist to prevent DoS attacks and to enforce overall application performance (bigger request size == more memory used from the server)