aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-bootstrap-upload/src
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-10-29 11:25:44 +0100
committerRobert Jaros <rjaros@finn.pl>2019-10-29 11:25:44 +0100
commitb72247f40f5948e5a5eb33d12632af0734668e11 (patch)
tree1e2986e27dc5be53064806f5d8e819dd8d90a2fc /kvision-modules/kvision-bootstrap-upload/src
parent4f99ecbedf1916320327778e50dfe021c1b98c01 (diff)
downloadkvision-b72247f40f5948e5a5eb33d12632af0734668e11.tar.gz
kvision-b72247f40f5948e5a5eb33d12632af0734668e11.tar.bz2
kvision-b72247f40f5948e5a5eb33d12632af0734668e11.zip
Fix native file handling in upload component (#98)
Diffstat (limited to 'kvision-modules/kvision-bootstrap-upload/src')
-rw-r--r--kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt14
1 files changed, 9 insertions, 5 deletions
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<KFile> {
nativeFiles.clear()
- return (getElementJQueryD()?.fileinput("getFileStack") as? Array<File>)?.toList()?.map {
- val kFile = KFile(it.name, it.size, null)
- nativeFiles[kFile] = it
- kFile
- } ?: listOf()
+ val fileStack = getElementJQueryD()?.fileinput("getFileStack")
+ val list = mutableListOf<KFile>()
+ 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
}
/**