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

@ -90,6 +90,8 @@ dependencies {
// TypeSafe Config: for simple and human friendly config files.
compile "com.typesafe:config:1.3.0"
compile "org.apache.httpcomponents:httpclient:4.5.2"
// Unit testing helpers.
testCompile 'junit:junit:4.12'
testCompile 'org.assertj:assertj-core:3.4.1'

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) }) {