Zstandard compression for Akka Stream
Zstandard for Akka Stream
Add the following lines to your build.sbt
.
// Add dependency of `akka-stream-zstd.git` on GitHub
dependsOn(RootProject(uri("https://github.com/nwtgck/akka-stream-zstd.git#v0.1.5")))
Here is an example to compress and store into a file
source
// Compress
.via(ZstdFlow.compress())
// Store to file
.runWith(FileIO.toPath(filePath))
Here is an example to decompress from a stored file and convert into a String
.
FileIO.fromPath(filePath)
// Decompress
.via(ZstdFlow.decompress())
// Concatenate into one ByteString
.runWith(Sink.fold(ByteString.empty)(_ ++ _))
// Convert ByteString to String
.map(_.utf8String)
Here is a full example.