1
我讀這https://www.playframework.com/documentation/2.4.x/ScalaWS但我無法確定如何發送post數據+文件。WS播放框架 - 如何發送文件
例如: 我想使用此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)
但這種情況並不奏效。任何消化或幫助我怎麼能做到這一點?