I am trying to download pdf file from S3 using the akka-stream-alpakka connector. I have the s3 path and try to download the pdf using a wrapper method over the alpakka s3Client.
def getSource(s3Path: String): Source[ByteString, NotUsed] = {
val (source, _) = s3Client.download(s3Bucket, s3Path)
source
}
From my main code, I call the above method, get the pdf source and am able to download the pdf. However, instead of downloading the file, I now need to have the pdf as an array of bytes in memory so that I can perform some other processing.
My current code looks something like this
val filePath = "certificate.pdf"
val value1: Future[IOResult] =
awsS3Bucket
.getSource(data.s3PdfPath)
.toMat(FileIO.toPath(Paths.get(filePath)))(Keep.right)
.run()
I tried a few combinations, but was unsuccessful. Can someone please point out what change needs to be made in the above code so as to have type of value1
an Future[Array[Bytes]]
instead of Future[IOResult]
.
TIA.