Skip to content

Instantly share code, notes, and snippets.

@tpolecat
Last active April 12, 2018 16:51
Show Gist options
  • Save tpolecat/75afdb7cfbe162d418f8266de51f7e26 to your computer and use it in GitHub Desktop.
Save tpolecat/75afdb7cfbe162d418f8266de51f7e26 to your computer and use it in GitHub Desktop.
val store =
Stream.bracket(IO(AmazonS3ClientBuilder.standard().build()))(
c => Stream.emit(S3Store[IO](c)),
a => IO(a.shutdown())
)
val prog1 =
store.flatMap { s3 =>
s3.list(Path("org.tpolecat.test1"))
.map(_.toString)
.through(text.utf8Encode)
.to(io.stdout)
}
val prog2 =
store.flatMap { s3 =>
Stream("hello")
.covary[IO]
.through(text.utf8Encode)
.to(s3.put(Path("org.tpolecat.test1/foo")))
}
prog1.compile.drain.unsafeRunSync // works, lists contents of bucket
prog2.compile.drain.unsafeRunSync // warns about content size and then hangs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment