in s3/src/main/scala/org/apache/pekko/stream/connectors/s3/scaladsl/S3.scala [47:485]
def request(bucket: String,
key: String,
method: HttpMethod = HttpMethods.GET,
versionId: Option[String] = None,
s3Headers: S3Headers = S3Headers.empty): Source[HttpResponse, NotUsed] =
S3Stream.request(S3Location(bucket, key), method, versionId = versionId, s3Headers = s3Headers.headers)
/**
* Gets the metadata for a S3 Object
*
* @param bucket the s3 bucket name
* @param key the s3 object key
* @param versionId optional version id of the object
* @param sse the server side encryption to use
* @return A [[pekko.stream.scaladsl.Source Source]] containing an [[scala.Option]] that will be [[scala.None]] in case the object does not exist
*/
def getObjectMetadata(
bucket: String,
key: String,
versionId: Option[String] = None,
sse: Option[ServerSideEncryption] = None): Source[Option[ObjectMetadata], NotUsed] =
getObjectMetadata(bucket, key, versionId, S3Headers.empty.withOptionalServerSideEncryption(sse))
/**
* Gets the metadata for a S3 Object
*
* @param bucket the s3 bucket name
* @param key the s3 object key
* @param versionId optional version id of the object
* @param s3Headers any headers you want to add
* @return A [[pekko.stream.scaladsl.Source Source]] containing an [[scala.Option]] that will be [[scala.None]] in case the object does not exist
*/
def getObjectMetadata(
bucket: String,
key: String,
versionId: Option[String],
s3Headers: S3Headers): Source[Option[ObjectMetadata], NotUsed] =
S3Stream.getObjectMetadata(bucket, key, versionId, s3Headers)
/**
* Deletes a S3 Object
*
* @param bucket the s3 bucket name
* @param key the s3 object key
* @param versionId optional version id of the object
* @return A [[pekko.stream.scaladsl.Source Source]] that will emit [[pekko.Done]] when operation is completed
*/
def deleteObject(bucket: String, key: String, versionId: Option[String] = None): Source[Done, NotUsed] =
deleteObject(bucket, key, versionId, S3Headers.empty)
/**
* Deletes a S3 Object
*
* @param bucket the s3 bucket name
* @param key the s3 object key
* @param versionId optional version id of the object
* @param s3Headers any headers you want to add
* @return A [[pekko.stream.scaladsl.Source Source]] that will emit [[pekko.Done]] when operation is completed
*/
def deleteObject(bucket: String,
key: String,
versionId: Option[String],
s3Headers: S3Headers): Source[Done, NotUsed] =
S3Stream.deleteObject(S3Location(bucket, key), versionId, s3Headers)
/**
* Deletes a S3 Objects which contain given prefix
*
* @param bucket the s3 bucket name
* @param prefix optional s3 objects prefix
* @return A [[pekko.stream.scaladsl.Source Source]] that will emit [[pekko.Done]] when operation is completed
*/
def deleteObjectsByPrefix(bucket: String, prefix: Option[String]): Source[Done, NotUsed] =
deleteObjectsByPrefix(bucket, prefix, S3Headers.empty)
/**
* Deletes a S3 Objects which contain given prefix
*
* @param bucket the s3 bucket name
* @param prefix optional s3 objects prefix
* @param deleteAllVersions Whether to delete all object versions as well (applies to versioned buckets)
* @return A [[pekko.stream.scaladsl.Source Source]] that will emit [[pekko.Done]] when operation is completed
*/
def deleteObjectsByPrefix(bucket: String, prefix: Option[String], deleteAllVersions: Boolean): Source[Done, NotUsed] =
deleteObjectsByPrefix(bucket, prefix, deleteAllVersions, S3Headers.empty)
/**
* Deletes a S3 Objects which contain given prefix
*
* @param bucket the s3 bucket name
* @param prefix optional s3 objects prefix
* @param s3Headers any headers you want to add
* @return A [[pekko.stream.scaladsl.Source Source]] that will emit [[pekko.Done]] when operation is completed
*/
def deleteObjectsByPrefix(bucket: String, prefix: Option[String], s3Headers: S3Headers): Source[Done, NotUsed] =
deleteObjectsByPrefix(bucket, prefix, deleteAllVersions = false, s3Headers)
/**
* Deletes a S3 Objects which contain given prefix
*
* @param bucket the s3 bucket name
* @param prefix optional s3 objects prefix
* @param deleteAllVersions Whether to delete all object versions as well (applies to versioned buckets)
* @param s3Headers any headers you want to add
* @return A [[pekko.stream.scaladsl.Source Source]] that will emit [[pekko.Done]] when operation is completed
*/
def deleteObjectsByPrefix(bucket: String,
prefix: Option[String],
deleteAllVersions: Boolean,
s3Headers: S3Headers): Source[Done, NotUsed] =
S3Stream.deleteObjectsByPrefix(bucket, prefix, deleteAllVersions, s3Headers)
/**
* Deletes all S3 Objects within the given bucket
*
* @param bucket the s3 bucket name
* @return A [[pekko.stream.scaladsl.Source Source]] that will emit [[pekko.Done]] when operation is completed
*/
def deleteBucketContents(bucket: String): Source[Done, NotUsed] =
deleteObjectsByPrefix(bucket, None, S3Headers.empty)
/**
* Deletes all S3 Objects within the given bucket
*
* @param bucket the s3 bucket name
* @param deleteAllVersions Whether to delete all object versions as well (applies to versioned buckets)
* @return A [[pekko.stream.scaladsl.Source Source]] that will emit [[pekko.Done]] when operation is completed
*/
def deleteBucketContents(bucket: String, deleteAllVersions: Boolean): Source[Done, NotUsed] =
deleteObjectsByPrefix(bucket, None, deleteAllVersions, S3Headers.empty)
/**
* Uploads a S3 Object, use this for small files and [[multipartUpload]] for bigger ones
*
* @param bucket the s3 bucket name
* @param key the s3 object key
* @param data a [[Stream]] of [[ByteString]]
* @param contentLength the number of bytes that will be uploaded (required!)
* @param contentType an optional [[ContentType]]
* @param s3Headers any headers you want to add
* @return a [[pekko.stream.scaladsl.Source Source]] containing the [[ObjectMetadata]] of the uploaded S3 Object
*/
def putObject(bucket: String,
key: String,
data: Source[ByteString, _],
contentLength: Long,
contentType: ContentType = ContentTypes.`application/octet-stream`,
s3Headers: S3Headers): Source[ObjectMetadata, NotUsed] =
S3Stream.putObject(S3Location(bucket, key), contentType, data, contentLength, s3Headers)
/**
* Downloads a S3 Object
*
* @param bucket the s3 bucket name
* @param key the s3 object key
* @param range [optional] the [[pekko.http.scaladsl.model.headers.ByteRange ByteRange]] you want to download
* @param sse [optional] the server side encryption used on upload
* @return The source will emit an empty [[scala.Option Option]] if an object can not be found.
* Otherwise [[scala.Option Option]] will contain a tuple of object's data and metadata.
*/
@deprecated("Use S3.getObject instead", "4.0.0")
def download(
bucket: String,
key: String,
range: Option[ByteRange] = None,
versionId: Option[String] = None,
sse: Option[ServerSideEncryption] = None)
: Source[Option[(Source[ByteString, NotUsed], ObjectMetadata)], NotUsed] =
download(bucket, key, range, versionId, S3Headers.empty.withOptionalServerSideEncryption(sse))
/**
* Downloads a S3 Object
*
* @param bucket the s3 bucket name
* @param key the s3 object key
* @param range [optional] the [[pekko.http.scaladsl.model.headers.ByteRange ByteRange]] you want to download
* @param s3Headers any headers you want to add
* @return The source will emit an empty [[scala.Option Option]] if an object can not be found.
* Otherwise [[scala.Option Option]] will contain a tuple of object's data and metadata.
*/
@deprecated("Use S3.getObject instead", "4.0.0")
def download(
bucket: String,
key: String,
range: Option[ByteRange],
versionId: Option[String],
s3Headers: S3Headers): Source[Option[(Source[ByteString, NotUsed], ObjectMetadata)], NotUsed] =
S3Stream.download(S3Location(bucket, key), range, versionId, s3Headers)
/**
* Gets a S3 Object
*
* @param bucket the s3 bucket name
* @param key the s3 object key
* @param range [optional] the [[pekko.http.scaladsl.model.headers.ByteRange ByteRange]] you want to download
* @param sse [optional] the server side encryption used on upload
* @return A [[pekko.stream.scaladsl.Source]] containing the objects data as a [[pekko.util.ByteString]] along with a materialized value containing the
* [[pekko.stream.connectors.s3.ObjectMetadata]]
*/
def getObject(
bucket: String,
key: String,
range: Option[ByteRange] = None,
versionId: Option[String] = None,
sse: Option[ServerSideEncryption] = None): Source[ByteString, Future[ObjectMetadata]] =
getObject(bucket, key, range, versionId, S3Headers.empty.withOptionalServerSideEncryption(sse))
/**
* Gets a S3 Object
*
* @param bucket the s3 bucket name
* @param key the s3 object key
* @param range [optional] the [[pekko.http.scaladsl.model.headers.ByteRange ByteRange]] you want to download
* @param s3Headers any headers you want to add
* @return A [[pekko.stream.scaladsl.Source]] containing the objects data as a [[pekko.util.ByteString]] along with a materialized value containing the
* [[pekko.stream.connectors.s3.ObjectMetadata]]
*/
def getObject(
bucket: String,
key: String,
range: Option[ByteRange],
versionId: Option[String],
s3Headers: S3Headers): Source[ByteString, Future[ObjectMetadata]] =
S3Stream.getObject(S3Location(bucket, key), range, versionId, s3Headers)
/**
* Will return a list containing all of the buckets for the current AWS account
*
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBuckets.html
* @return [[pekko.stream.scaladsl.Source Source]] of [[ListBucketsResultContents]]
*/
def listBuckets(): Source[ListBucketsResultContents, NotUsed] =
listBuckets(S3Headers.empty)
/**
* Will return a list containing all of the buckets for the current AWS account
*
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBuckets.html
* @param s3Headers any headers you want to add
* @return [[pekko.stream.scaladsl.Source Source]] of [[ListBucketsResultContents]]
*/
def listBuckets(s3Headers: S3Headers): Source[ListBucketsResultContents, NotUsed] =
S3Stream.listBuckets(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.
*
* The `pekko.connectors.s3.list-bucket-api-version` can be set to 1 to use the older API version 1
*
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html (version 2 API)
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjects.html (version 1 API)
* @param bucket Which bucket that you list object metadata for
* @param prefix Prefix of the keys you want to list under passed bucket
* @return [[pekko.stream.scaladsl.Source Source]] of [[ListBucketResultContents]]
*/
def listBucket(bucket: String, prefix: Option[String]): Source[ListBucketResultContents, NotUsed] =
listBucket(bucket, prefix, S3Headers.empty)
/**
* 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.
*
* The `pekko.connectors.s3.list-bucket-api-version` can be set to 1 to use the older API version 1
*
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html (version 2 API)
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjects.html (version 1 API)
* @param bucket Which bucket that you list object metadata for
* @param prefix Prefix of the keys you want to list under passed bucket
* @param s3Headers any headers you want to add
* @return [[pekko.stream.scaladsl.Source Source]] of [[ListBucketResultContents]]
*/
def listBucket(bucket: String,
prefix: Option[String],
s3Headers: S3Headers): Source[ListBucketResultContents, NotUsed] =
S3Stream.listBucket(bucket, prefix, s3Headers)
/**
* Will return a source of object metadata for a given bucket and delimiter with optional prefix using version 2 of the List Bucket API.
* This will automatically page through all keys with the given parameters.
*
* The `pekko.connectors.s3.list-bucket-api-version` can be set to 1 to use the older API version 1
*
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html (version 2 API)
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjects.html (version 1 API)
* @param bucket Which bucket that you list object metadata for
* @param prefix Prefix of the keys you want to list under passed bucket
* @param s3Headers any headers you want to add
* @return [[pekko.stream.scaladsl.Source Source]] of [[ListBucketResultContents]]
*/
def listBucket(bucket: String,
delimiter: String,
prefix: Option[String] = None,
s3Headers: S3Headers = S3Headers.empty): Source[ListBucketResultContents, NotUsed] =
S3Stream
.listBucketAndCommonPrefixes(bucket, delimiter, prefix, s3Headers)
.mapConcat(_._1)
/**
* Will return a source of object metadata and common prefixes for a given bucket and delimiter with optional prefix using version 2 of the List Bucket API.
* This will automatically page through all keys with the given parameters.
*
* The `pekko.connectors.s3.list-bucket-api-version` can be set to 1 to use the older API version 1
*
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html (version 2 API)
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjects.html (version 1 API)
* @see https://docs.aws.amazon.com/AmazonS3/latest/dev/ListingKeysHierarchy.html (prefix and delimiter documentation)
* @param bucket Which bucket that you list object metadata for
* @param delimiter Delimiter to use for listing only one level of hierarchy
* @param prefix Prefix of the keys you want to list under passed bucket
* @param s3Headers any headers you want to add
* @return [[pekko.stream.scaladsl.Source Source]] of ([[scala.collection.Seq Seq]] of [[pekko.stream.connectors.s3.ListBucketResultContents ListBucketResultContents]], [[scala.collection.Seq Seq]] of [[pekko.stream.connectors.s3.ListBucketResultContents ListBucketResultContents]])
*/
def listBucketAndCommonPrefixes(
bucket: String,
delimiter: String,
prefix: Option[String] = None,
s3Headers: S3Headers = S3Headers.empty)
: Source[(Seq[ListBucketResultContents], Seq[ListBucketResultCommonPrefixes]), NotUsed] =
S3Stream.listBucketAndCommonPrefixes(bucket, delimiter, prefix, s3Headers)
/**
* Will return in progress or aborted multipart uploads. This will automatically page through all keys with the given parameters.
*
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListMultipartUploads.html
* @param bucket Which bucket that you list in-progress multipart uploads for
* @param prefix Prefix of the keys you want to list under passed bucket
* @return [[pekko.stream.scaladsl.Source Source]] of [[ListMultipartUploadResultUploads]]
*/
def listMultipartUpload(bucket: String, prefix: Option[String]): Source[ListMultipartUploadResultUploads, NotUsed] =
listMultipartUpload(bucket, prefix, S3Headers.empty)
/**
* Will return in progress or aborted multipart uploads. This will automatically page through all keys with the given parameters.
*
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListMultipartUploads.html
* @param bucket Which bucket that you list in-progress multipart uploads for
* @param prefix Prefix of the keys you want to list under passed bucket
* @param s3Headers any headers you want to add
* @return [[pekko.stream.scaladsl.Source Source]] of [[ListMultipartUploadResultUploads]]
*/
def listMultipartUpload(bucket: String,
prefix: Option[String],
s3Headers: S3Headers): Source[ListMultipartUploadResultUploads, NotUsed] =
S3Stream.listMultipartUpload(bucket, prefix, s3Headers)
/**
* Will return in progress or aborted multipart uploads with optional prefix and delimiter. This will automatically page through all keys with the given parameters.
*
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListMultipartUploads.html
* @param bucket Which bucket that you list in-progress multipart uploads for
* @param delimiter Delimiter to use for listing only one level of hierarchy
* @param prefix Prefix of the keys you want to list under passed bucket
* @param s3Headers any headers you want to add
* @return [[pekko.stream.scaladsl.Source Source]] of ([[scala.collection.Seq Seq]] of [[pekko.stream.connectors.s3.ListMultipartUploadResultUploads ListMultipartUploadResultUploads]], [[scala.collection.Seq Seq]] of [[pekko.stream.connectors.s3.CommonPrefixes CommonPrefixes]])
*/
def listMultipartUploadAndCommonPrefixes(
bucket: String,
delimiter: String,
prefix: Option[String] = None,
s3Headers: S3Headers = S3Headers.empty)
: Source[(Seq[ListMultipartUploadResultUploads], Seq[CommonPrefixes]), NotUsed] =
S3Stream.listMultipartUploadAndCommonPrefixes(bucket, delimiter, prefix, s3Headers)
/**
* List uploaded parts for a specific upload. This will automatically page through all keys with the given parameters.
*
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html
* @param bucket Under which bucket the upload parts are contained
* @param key They key where the parts were uploaded to
* @param uploadId Unique identifier of the upload for which you want to list the uploaded parts
* @return [[pekko.stream.scaladsl.Source Source]] of [[ListPartsResultParts]]
*/
def listParts(bucket: String, key: String, uploadId: String): Source[ListPartsResultParts, NotUsed] =
listParts(bucket, key, uploadId, S3Headers.empty)
/**
* List uploaded parts for a specific upload. This will automatically page through all keys with the given parameters.
*
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html
* @param bucket Under which bucket the upload parts are contained
* @param key They key where the parts were uploaded to
* @param uploadId Unique identifier of the upload for which you want to list the uploaded parts
* @param s3Headers any headers you want to add
* @return [[pekko.stream.scaladsl.Source Source]] of [[ListPartsResultParts]]
*/
def listParts(bucket: String,
key: String,
uploadId: String,
s3Headers: S3Headers): Source[ListPartsResultParts, NotUsed] =
S3Stream.listParts(bucket, key, uploadId, s3Headers)
/**
* List all versioned objects for a bucket with optional prefix. This will automatically page through all keys with the given parameters.
*
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectVersions.html
* @param bucket Which bucket that you list object versions for
* @param prefix Prefix of the keys you want to list under passed bucket
* @return [[pekko.stream.scaladsl.Source Source]] of ([[scala.collection.Seq Seq]] of [[pekko.stream.connectors.s3.ListObjectVersionsResultVersions ListObjectVersionsResultVersions]], [[scala.collection.Seq Seq]] of [[pekko.stream.connectors.s3.DeleteMarkers DeleteMarkers]])
*/
def listObjectVersions(
bucket: String,
prefix: Option[String]): Source[(Seq[ListObjectVersionsResultVersions], Seq[DeleteMarkers]), NotUsed] =
S3Stream.listObjectVersions(bucket, prefix, S3Headers.empty)
/**
* List all versioned objects for a bucket with optional prefix. This will automatically page through all keys with the given parameters.
*
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectVersions.html
* @param bucket Which bucket that you list object versions for
* @param prefix Prefix of the keys you want to list under passed bucket
* @param s3Headers any headers you want to add
* @return [[pekko.stream.scaladsl.Source Source]] of ([[scala.collection.Seq Seq]] of [[pekko.stream.connectors.s3.ListObjectVersionsResultVersions ListObjectVersionsResultVersions]], [[scala.collection.Seq Seq]] of [[pekko.stream.connectors.s3.DeleteMarkers DeleteMarkers]])
*/
def listObjectVersions(
bucket: String,
prefix: Option[String],
s3Headers: S3Headers): Source[(Seq[ListObjectVersionsResultVersions], Seq[DeleteMarkers]), NotUsed] =
S3Stream.listObjectVersions(bucket, prefix, s3Headers)
/**
* List all versioned objects for a bucket with optional prefix and delimiter. This will automatically page through all keys with the given parameters.
*
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectVersions.html
* @param bucket Which bucket that you list object versions for
* @param delimiter Delimiter to use for listing only one level of hierarchy
* @param prefix Prefix of the keys you want to list under passed bucket
* @param s3Headers any headers you want to add
* @return [[pekko.stream.scaladsl.Source Source]] of ([[scala.collection.Seq Seq]] of [[pekko.stream.connectors.s3.ListObjectVersionsResultVersions ListObjectVersionsResultVersions]], [[scala.collection.Seq Seq]] of [[pekko.stream.connectors.s3.DeleteMarkers DeleteMarkers]])
*/
def listObjectVersions(
bucket: String,
delimiter: String,
prefix: Option[String],
s3Headers: S3Headers): Source[(Seq[ListObjectVersionsResultVersions], Seq[DeleteMarkers]), NotUsed] =
S3Stream.listObjectVersionsAndCommonPrefixes(bucket, delimiter, prefix, s3Headers).map {
case (versions, markers, _) =>
(versions, markers)
}