Last active
August 29, 2015 14:08
-
-
Save hochgi/36e789c71f32caed5a86 to your computer and use it in GitHub Desktop.
Dispath with custom data sources (example with InputStream)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dispatch._ ,Defaults._ | |
import com.ning.http.client.Request.EntityWriter | |
import org.apache.commons.compress.utils.IOUtils | |
import java.io.{InputStream, OutputStream} | |
implicit def InputStream2EntityWriter(in: InputStream): EntityWriter = new EntityWriter { | |
override def writeEntity(out: OutputStream): Unit = { | |
IOUtils.copy(in,out) | |
in.close | |
out.close | |
} | |
} | |
val r: Req = //... | |
val in: InputStream = //... | |
r setBody(in) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment