Error now occurs on upload if no files are sent. Added apache httpcomponents as a dependency.

This commit is contained in:
Clinton Alexander
2016-06-07 10:26:51 +01:00
committed by Andras Slemmer
parent b050411810
commit f6069e1e15
2 changed files with 9 additions and 0 deletions

View File

@ -35,6 +35,13 @@ class DataUploadServlet : HttpServlet() {
val upload = ServletFileUpload()
val iterator = upload.getItemIterator(req)
val messages = ArrayList<String>()
if(!iterator.hasNext())
{
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Got an upload request with no files")
return
}
while (iterator.hasNext()) {
val item = iterator.next()
if (item.name != null && !acceptor.acceptableFileExtensions.any { item.name.endsWith(it) }) {