Преглед изворни кода

Merge branch 'master' of masarifyuli/ipphone-bridge-fork into master

ok terimakasih
herlanS_ пре 2 година
родитељ
комит
e94c455eb4
1 измењених фајлова са 14 додато и 8 уклоњено
  1. 14 8
      src/main/kotlin/co/id/datacomsolusindo/ipphonebridge/BridgeFIlter.kt

+ 14 - 8
src/main/kotlin/co/id/datacomsolusindo/ipphonebridge/BridgeFIlter.kt

@@ -85,14 +85,20 @@ class BridgeFilter(private val template: SimpMessagingTemplate, val resourceLoad
                     if (req.contentType?.toLowerCase()?.contains("multipart/form-data") == true) {
                         rb.parts =
                             req.parts.map {
-                                val subFilename = if (it.submittedFileName == null) {
-                                    UUID.randomUUID().toString().take(5)
-                                } else {
-                                    it.submittedFileName
-                                }
-
-                                val fb64 = Base64.getEncoder().encodeToString(it.inputStream.readBytes())
-                                FilePart(it.name, subFilename, fb64)
+                                it.contentType?.let { con ->
+                                    if (con.contains("text/plain;"))
+                                        FilePart(it.name, "isNotFile", String(it.inputStream.readBytes()))
+                                    else {
+                                        val subFilename = if (it.submittedFileName == null) {
+                                            UUID.randomUUID().toString().take(5)
+                                        } else {
+                                            it.submittedFileName
+                                        }
+
+                                        val fb64 = Base64.getEncoder().encodeToString(it.inputStream.readBytes())
+                                        FilePart(it.name, subFilename, fb64)
+                                    }
+                                } ?: FilePart(it.name, "isNotFile", String(it.inputStream.readBytes()))
                             }.toMutableList()
                     } else {
                         val body = req.reader.lines().toList().joinToString(System.lineSeparator())