From b72247f40f5948e5a5eb33d12632af0734668e11 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Tue, 29 Oct 2019 11:25:44 +0100 Subject: Fix native file handling in upload component (#98) --- .../kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'kvision-modules/kvision-bootstrap-upload/src/main') diff --git a/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt b/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt index da05b04c..20859ad7 100644 --- a/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt +++ b/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt @@ -264,11 +264,15 @@ open class UploadInput(uploadUrl: String? = null, multiple: Boolean = false, cla private fun getFiles(): List { nativeFiles.clear() - return (getElementJQueryD()?.fileinput("getFileStack") as? Array)?.toList()?.map { - val kFile = KFile(it.name, it.size, null) - nativeFiles[kFile] = it - kFile - } ?: listOf() + val fileStack = getElementJQueryD()?.fileinput("getFileStack") + val list = mutableListOf() + for (key in js("Object").keys(fileStack)) { + val nativeFile = fileStack[key].file as File + val kFile = KFile(nativeFile.name, nativeFile.size, null) + nativeFiles[kFile] = nativeFile + list += kFile + } + return list } /** -- cgit