我读了这个https://www.playframework.com/documentation/2.4.x/ScalaWS,但我无法弄清楚如何发送帖子数据+文件。
实施例: 我想使用此API https://code.google.com/p/imagebam-api/wiki/UploadImage上传图片,但我不知道如何。我试过这个:
val file:File = new File("c:/file/sample.jpg")
val postMap = Map(
"oauth_consumer_key" -> Seq(apiKey.toString),
"oauth_signature_method" -> Seq(oauthSignatureMethod.toString),
"oauth_signature" -> Seq(oauthSignature.toString),
"oauth_timestamp" -> Seq(oauthTimestAmp.toString),
"oauth_nonce" -> Seq(oauthNonce.toString),
"oauth_token" -> Seq(oauthToken.toString),
"content_type" -> Seq("adult"),
"thumb_format" -> Seq("JPG"),
"thumb_size" -> Seq("350x350"),
"thumb_cropping" -> Seq(0.toString),
"thumb_info" -> Seq(1.toString),
"response_format" -> Seq("JSON"),
"image" -> Seq(file)
)
val bb_SendImg = WS.url("http://www.imagebam.com/sys/API/resource/upload_image").post(postMap)
但这不起作用。任何消化或帮助我该怎么做?
答案 0 :(得分:0)