Quantcast
Channel: Akka Libraries - Discussion Forum for Akka technologies
Viewing all articles
Browse latest Browse all 1362

New to Alpakka, question about downloading file(s)

$
0
0

@moyphilip wrote:

Hello,

I have been trying to figure a way to download a file from s3. I want to:

  1. list the files from s3://bucket/key
  2. filter for csv files.
  3. write them to a local directory

I have been working with this code but can’t get it to work. I am unfamiliar with how graph works. Can someone point me in the right direction.

  val test = S3.listBucket(bucket, Option(key))
    .filter(a => a.key.endsWith("csv"))
    .map(r => S3.download(r.bucketName, r.key))
    .to(FileIO.toPath(downloadPath))
    .run()

I am trying to make it a Future[Done] so I can call on complete to it and close out the system.

This code works but I dont know how to close out the system after running the graph to completion

  val test = s3List
    .filter(a => a.key.endsWith("csv"))
    .map(r => S3.download(r.bucketName, r.key))
    .flatMapConcat(identity)
    .collect{case Some(x) => x}
    .flatMapConcat{case (s, o) => s}
    .to(FileIO.toPath(downloadPath))

  test.run()

Posts: 6

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 1362

Trending Articles