Skip to content

Commit

Permalink
createBucket function for integration testing pupose only, akka#938
Browse files Browse the repository at this point in the history
  • Loading branch information
sfali committed Jun 7, 2018
1 parent 49c9dc2 commit e023b4f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions s3/src/main/scala/akka/stream/alpakka/s3/impl/S3Stream.scala
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ private[alpakka] final class S3Stream(settings: S3Settings)(implicit system: Act
(source, meta)
}

def createBucket(bucket: String, s3Headers: S3Headers = S3Headers.empty): Future[String] = {
import mat.executionContext
HttpRequests
.createBucket(bucket, s3Headers)
.flatMap(signAndGet)
.map { response =>
response.headers.find(_.lowercaseName() == "location").map(_.value()).getOrElse("Unknown")
}
}

def listBucket(bucket: String, prefix: Option[String] = None): Source[ListBucketResultContents, NotUsed] = {
sealed trait ListBucketState
case object Starting extends ListBucketState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ final class S3Client(val s3Settings: S3Settings)(implicit system: ActorSystem, m
sse: Option[ServerSideEncryption] = None): (Source[ByteString, NotUsed], Future[ObjectMetadata]) =
impl.download(S3Location(bucket, key), range, versionId, sse)

private[scaladsl] def createBucket(bucket: String, s3Headers: S3Headers = S3Headers.empty): Future[String] =
impl.createBucket(bucket, s3Headers)

/**
* Will return a source of object metadata for a given bucket with optional prefix using version 2 of the List Bucket API.
* This will automatically page through all keys with the given parameters.
Expand Down

0 comments on commit e023b4f

Please sign in to comment.