Is there a possibility to do a multipart request w...
# kvision
j
Is there a possibility to do a multipart request without using Upload form control ? I see that RestClient isn't compliant with multipart. In my case Upload control is just a tool to get a file before modifying it. After this modification, I would like to add it to an authenticate multipart request that for now didn't know or see any way to make this multipart request
r
Where do you keep your file data on the client side? A byte array? A base64 string?
j
It's a byte array
Is KFile content a base64 string ? Do you suggest to send a simple json to upload files ?
r
you could try this:
Copy code
val byteArray = byteArrayOf(1, 2, 3)
            val blob = Blob(arrayOf(byteArray), BlobPropertyBag("application/octet-stream"))
            val formData = FormData()
            formData.append("test", blob, "test.dat")
            val result = RestClient().remoteCall("<http://localhost:5555>", formData, <http://HttpMethod.POST|HttpMethod.POST>, "multipart/form-data")
            result.then<dynamic> {
                console.log(it)
            }
j
Ahhh that makes sense. Thank you very much for your help.