Skip to content

Instantly share code, notes, and snippets.

@bszwej
Created July 31, 2017 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bszwej/a5536edf832538da5e39a916008f549e to your computer and use it in GitHub Desktop.
Save bszwej/a5536edf832538da5e39a916008f549e to your computer and use it in GitHub Desktop.
Source.fromPublisher(collection.find(): Publisher[org.bson.Document])
.map((doc: org.bson.Document) ⇒ doc.toJson())
.map((json: String) ⇒ ByteString(json))
.via(Compression.gzip: Flow[ByteString, ByteString, NotUsed])
.runWith(s3Sink)
val s3Sink: Sink[ByteString, Future[MultipartUploadResult]] =
s3Client.multipartUploadWithHeaders(
bucket = "mycookiesbucket12345",
key = "CookieCollectionBackup.json",
s3Headers = Some(S3Headers(ServerSideEncryption.AES256))
)
The full runnable code can be found here:
https://github.com/bszwej/mongodb-s3-stream-example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment