Use play wsClient for upload multiple files

scala

(Ashan Iroshan) #1

is there way to upload multiple files using wsClient.??


(Marcos Pereira) #2

Yes,

If you look at WSRequest class, there is a post/put method where you can submit a Source[Part[Source[ByteString, _]], _] and Part can be a FilePart.

Best.


(Ashan Iroshan) #3

hi
@marcospereira
i able to work with one file. but i need to upload list of file at once.can i put multiple files ??
val responser = ws.url(“http://localhost:9000/api/hello/”)
.addQueryStringParameters(“patientHealthId” -> patientId.toString)
.addQueryStringParameters(“path” -> path)

.post(Source(FilePart(files.head.filename, files.head.filename, Option(files.head.contentType.get), FileIO.fromPath(files.head.ref.path)) :: DataPart(“key”, “value”) :: List()))