0
PlayFramework文檔顯示上傳文件非常簡單。如何從playframework中的字符串上傳文件?
https://www.playframework.com/documentation/2.5.x/ScalaWS
ws.url(url).post(Source(FilePart("hello", "hello.txt", Option("text/plain"), FileIO.fromFile(tmpFile)) :: DataPart("key", "value") :: List()))
但是,如果文件內容已經在內存?任何替代方法FileIO.fromFile
,如FileIO.fromString(jsontStr)?
val jsonStr = """{ foo: "Bar"} """
ws.url(url).post(Source(FilePart("hello", "hello.json", Option("application/json"), FileIO.fromString(jsonStr)) :: DataPart("key", "value") :: List()))
感謝您的快速回答! – ruimo