Skip to content

Instantly share code, notes, and snippets.

@hochgi
Last active August 29, 2015 14:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hochgi/36e789c71f32caed5a86 to your computer and use it in GitHub Desktop.
Save hochgi/36e789c71f32caed5a86 to your computer and use it in GitHub Desktop.
Dispath with custom data sources (example with InputStream)
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