<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Bernhard,<div class=""><br class=""></div><div class="">imho, it’s better practice to detect too large file upload in your app on the client side, i.e. before your user has been uploading xxx MB. For that, you can check out various client-side programs like jQuery-FileUpload (<a href="https://blueimp.github.io/jQuery-File-Upload/" class="">https://blueimp.github.io/jQuery-File-Upload/</a>)</div><div class=""><br class=""></div><div class="">You also might want to check out this: <a href="http://jbrichau.github.io/blog/large-file-upload-in-seaside" class="">http://jbrichau.github.io/blog/large-file-upload-in-seaside</a></div><div class="">And Nick’s original post has come back online since I wrote mine too: <a href="http://nickager.com/blog/2011/07/01/File-upload-using-Nginx-and-Seaside" class="">http://nickager.com/blog/2011/07/01/File-upload-using-Nginx-and-Seaside</a><br class=""><div class=""><div class=""><br class=""></div><div class="">The adaptor framework was built to minimize dependencies between Seaside and the http server. To make Seaside aware about an error occurring inside the http server, and allow to produce a response to it, a specialized extension of the adaptor is necessary. I think you _can_ make a nice looking page using Seaside when you tell Zinc that it should respond to the error using Seaside. Both Zinc and Seaside are frameworks and you can customize them by specializing appropriate methods. If you create your own ZnSeasideServerAdaptorDelegate and override #handleRequest: to catch the error, you can dispatch to the Seaside framework to render a nice looking page. </div><div class=""><br class=""></div><div class="">There are several ways to dispatch back to Seaside. The easiest way would be to generate a generic page using the WABuilder:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">    </span>WAHtmlCanvas builder render: [ :html | html text: ‘Oops… entity too large!’ ]</div><div class=""><br class=""></div><div class="">However, that does not dispatch back to your running app and you probably expect to be able to specify some other callback in your Seaside code that would execute on that error? This would make your app dependent on Zinc though (and the Seaside framework would need be extended to handle that additional dependency on adaptors). Not sure if all that work makes sense when this kind of upload error is preferably handled differently.</div><div class=""><br class=""></div><div class="">cheers</div><div class="">Johan</div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 20 Jan 2017, at 07:04, Bernhard Pieber <<a href="mailto:bernhard@pieber.com" class="">bernhard@pieber.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Thank you for your answer, Sven.<br class=""><br class="">That’s a bummer. If I understand you correctly, currently there is no hook in Seaside to catch lower level server exceptions (like ZnEntityTooLarge) to show a nice looking error page, e.g. „You are trying to upload a file that’s too large. Don’t do that!“ Really? :-/<br class=""><br class="">Cheers,<br class="">Bernhard<br class=""><br class=""><blockquote type="cite" class="">Am 19.01.2017 um 14:29 schrieb Sven Van Caekenberghe <<a href="mailto:sven@stfx.eu" class="">sven@stfx.eu</a>>:<br class=""><br class="">Hi Bernard,<br class=""><br class="">Your analysis is correct. <br class=""><br class="">Most Seaside adaptors, including ZnZincServerAdaptor, are implemented so that the incoming (Zn) request is read from the wire, then converted to Seaside WA* objects, processed, the result converted from WA* objects to an outgoing (Zn) response and put on the wire.<br class=""><br class="">Zn has some built-in resource protection measures, including a limit on how large entities (bodies) can be. The error of crossing such a limit is raised in the very first step, outside the scope of your Seaside handling code.<br class=""><br class="">At first sight, I would not immediately know how this can be solved. <br class=""><br class="">Note that in order to know how much is coming in, you have to read it, but you have to stop in time. Note also that the content-length header could be absent or wrong (a malicious request).<br class=""><br class="">I can't remember where we currently stand on a streaming Zn Seaside adaptor, there were some experiments in the past IIRC. That could be a solution, because then the entity/body is not read until further down the line, if we can get it to work. The current one only seems to do streaming for responses.<br class=""><br class="">Sven<br class=""><br class=""><blockquote type="cite" class="">On 19 Jan 2017, at 13:32, Bernhard Pieber <<a href="mailto:bernhard@pieber.com" class="">bernhard@pieber.com</a>> wrote:<br class=""><br class="">I have a Seaside application which includes a file upload feature.<br class=""><br class="">renderContentOn: html<br class="">…<br class="">html fileUpload<br class=""><span class="Apple-tab-span" style="white-space:pre">    </span>callback: [ :file | self receiveFile: file ].<br class=""><span class="Apple-tab-span" style="white-space:pre">  </span>html submitButton: 'Upload‘ ]<br class="">…<br class=""><br class="">In receiveFile: I just save the uploaded file on the file system.<br class=""><br class="">When I upload a file larger than 16 MB an error page is shown with the error message:<br class="">Bad Request ZnEntityTooLarge<br class=""><br class="">I found that by using ZnConstants>>maximumEntitySize: I can increase this limit. However, I want to catch this in the image and show an error message to the user.<br class=""><br class="">I tried wrapping receiveFile: and renderContentOn: with an on:do: exception handler for ZnEntityTooLarge. However, neither works. It seems that the error happens before renderContentOn: is even called. I searched the mailing lists but did not come up with an answer.<br class=""><br class="">How can I achieve this in Seaside? Any help would be much appreciated.<br class=""><br class="">Cheers,<br class="">Bernhard<br class="">_______________________________________________<br class="">seaside mailing list<br class=""><a href="mailto:seaside@lists.squeakfoundation.org" class="">seaside@lists.squeakfoundation.org</a><br class="">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside<br class=""></blockquote><br class=""><br class=""></blockquote><br class="">_______________________________________________<br class="">seaside mailing list<br class=""><a href="mailto:seaside@lists.squeakfoundation.org" class="">seaside@lists.squeakfoundation.org</a><br class="">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside<br class=""></div></div></blockquote></div><br class=""></div></div></div></body></html>