Skip to content

Commit

Permalink
Refactored adding of Range header to download request for S3
Browse files Browse the repository at this point in the history
  • Loading branch information
thereisnospoon committed Apr 15, 2017
1 parent 87aa586 commit c222aeb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions s3/src/main/scala/akka/stream/alpakka/s3/impl/S3Stream.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ private[alpakka] final class S3Stream(credentials: AWSCredentials,
Source.fromFuture(request(s3Location, range).flatMap(entityForSuccess).map(_.dataBytes)).flatMapConcat(identity)
}

def request(s3Location: S3Location, range: Option[ByteRange] = None): Future[HttpResponse] = {
def request(s3Location: S3Location, rangeOption: Option[ByteRange] = None): Future[HttpResponse] = {
val downloadRequest = getDownloadRequest(s3Location, region)
val rangeHeader = range.map(headers.Range(_))
signAndGet(rangeHeader.map(downloadRequest.withHeaders(_)).getOrElse(downloadRequest))
signAndGet(rangeOption match {
case Some(range) => downloadRequest.withHeaders(headers.Range(range))
case _ => downloadRequest
})
}

/**
Expand Down

0 comments on commit c222aeb

Please sign in to comment.