0

I'm in the midst of adding file upload support to my Scalatra application, and I followed the official docs, but the approach doesn't seem to work for ScalatraFilters--only ScalatraServlets.

For example, if I just generate a new Scalatra project, then extend the ScalatraServlet with FileUploadSupport (with configureMultipartHandling beneath as noted, or in the web.xml file), everything works fine, but if I switch that ScalatraServlet to a ScalatraFilter, there doesn't seem to be any support--despite the codebase noting that "FileUploadSupport can be mixed into a [[org.scalatra.ScalatraFilter]] or [[org.scalatra.ScalatraServlet]]".

Does anyone have advice as to how I can include FileUploadSupport when I'm working with a ScalatraFilter rather than a ScalatraServlet? Maybe I'm just missing something obvious, here.

Katherine
  • 47
  • 1
  • 4

1 Answers1

0

It's not clear what "doesn't seem to be any support" means from your question, but in a quick experiment changing the extending class from a ScalatraServlet to a ScalatraFilter, I encountered different route handling.

My experiments show that FileUploadSupport is supported for a ScalatraFilter, however I noticed that the same path didn't work when it was converted to a filter. Here are some results:

ScalatraBootstrap route | router get() | worked for
------------------------------------------------------
"/upload/*"             | "/"          | servlet
"/"                     | "/upload"    | filter ( like their FilterExample setup )
"/upload"               | "/upload"    | filter

In each case, the "worked for" means that I was able to see the example form listed on the upload documentation page. Clicking on the browse button opened an finder window from an FF browser. I have scalatra 2.10-2.2.2 if that makes a difference. I used the same route for the post() function in my "upload router" and was able to output some info from the upload in each case.

n0741337
  • 2,474
  • 2
  • 15
  • 15