1
votes

I implemented a limit on the size that users can upload images to the GAE blobstore using the UploadOptions method. When the file size uploaded is too large, I get redirected to this page:

Error 413 Your client issued a request that was too large. Maximum upload size per blob limit exceeded.

How can I prevent the redirect? I want to provide a meaningful message to tell users that the file size is too large on the current page.

My code for uploading:

<form action="<%= blobstoreService.createUploadUrl("/upload", UploadOptions.Builder.withMaxUploadSizeBytes((512000))%>" method="post" enctype="multipart/form-data">
2

2 Answers

4
votes

Submit the form with an ajax request. The response code is there and you can act on it accordingly.

0
votes

Or, you can edit the error page if you want a custom message. There's a way to define a default page or a static page for each one of the error page, in your case, 413.

Check: https://developers.google.com/appengine/docs/java/config/webxml?hl=en#Error_Handlers