object S3
Singleton object provides builders for S3.
Example
import monix.eval.Task import software.amazon.awssdk.services.s3.model.NoSuchKeyException val bucket = "my-bucket" val key = "my-key" val content = "my-content" def runS3App(s3: S3): Task[Array[Byte]] = { for { _ <- s3.createBucket(bucket) _ <- s3.upload(bucket, key, content.getBytes) existsObject <- s3.existsObject(bucket, key) download <- { if(existsObject) s3.download(bucket, key) else Task.raiseError(NoSuchKeyException.builder().build()) } } yield download } val t = S3.fromConfig.use(s3 => runS3App(s3))
- Source
- S3.scala
- Alphabetic
- By Inheritance
- S3
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def create(credentialsProvider: AwsCredentialsProvider, region: Region, endpoint: Option[String] = None, httpClient: Option[SdkAsyncHttpClient] = None): Resource[Task, S3]
Creates a Resource that using passed-by-parameter AWS configurations, it encodes the acquisition and release of the resources needed to instantiate the S3.
Creates a Resource that using passed-by-parameter AWS configurations, it encodes the acquisition and release of the resources needed to instantiate the S3.
Example
import cats.effect.Resource import monix.eval.Task import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider import software.amazon.awssdk.regions.Region val defaultCredentials = DefaultCredentialsProvider.create() val s3Resource: Resource[Task, S3] = S3.create(defaultCredentials, Region.AWS_GLOBAL)
- credentialsProvider
strategy for loading credentials and authenticate to AWS S3
- region
an Amazon Web Services region that hosts a set of Amazon services.
- endpoint
the endpoint with which the SDK should communicate.
- httpClient
sets the SdkAsyncHttpClient that the SDK service client will use to make HTTP calls.
- returns
a Resource of Task that allocates and releases S3.
- def createUnsafe(credentialsProvider: AwsCredentialsProvider, region: Region, endpoint: Option[String] = None, httpClient: Option[SdkAsyncHttpClient] = None): S3
Creates a new S3 instance out of the the passed AWS configurations.
Creates a new S3 instance out of the the passed AWS configurations.
It provides a fast forward access to the S3 that avoids dealing with Resource, however in this case, the created resources will not be released like in create.
Thus, it is the user's responsibility of the user to do a proper resource usage and closing the connection.
Example
import monix.execution.Scheduler.Implicits.global import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider import software.amazon.awssdk.regions.Region val defaultCred = DefaultCredentialsProvider.create() val s3: S3 = S3.createUnsafe(defaultCred, Region.AWS_GLOBAL) // do your stuff here s3.close.runToFuture
- credentialsProvider
Strategy for loading credentials and authenticate to AWS S3
- region
An Amazon Web Services region that hosts a set of Amazon services.
- endpoint
The endpoint with which the SDK should communicate.
- httpClient
Sets the SdkAsyncHttpClient that the SDK service client will use to make HTTP calls.
- returns
a Resource of Task that allocates and releases a S3.
- Annotations
- @UnsafeBecauseImpure()
- def createUnsafe(s3AsyncClient: S3AsyncClient): S3
Creates a instance of S3 out of a S3AsyncClient.
Creates a instance of S3 out of a S3AsyncClient.
It provides a fast forward access to the S3 that avoids dealing with Resource.
Unsafe because the state of the passed S3AsyncClient is not guaranteed, it can either be malformed or closed, which would result in underlying failures.
Example
import java.time.Duration import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider import software.amazon.awssdk.regions.Region.AWS_GLOBAL import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient import software.amazon.awssdk.services.s3.S3AsyncClient // the exceptions related with concurrency or timeouts from any of the requests // might be solved by raising the `maxConcurrency`, `maxPendingConnectionAcquire` or // `connectionAcquisitionTimeout` from the underlying netty http async client. // see below an example on how to increase such values. val httpClient = NettyNioAsyncHttpClient.builder() .maxConcurrency(500) .maxPendingConnectionAcquires(50000) .connectionAcquisitionTimeout(Duration.ofSeconds(60)) .readTimeout(Duration.ofSeconds(60)) .build() val s3AsyncClient: S3AsyncClient = S3AsyncClient .builder() .httpClient(httpClient) .credentialsProvider(DefaultCredentialsProvider.create()) .region(AWS_GLOBAL) .build() val s3: S3 = S3.createUnsafe(s3AsyncClient)
- s3AsyncClient
an instance of a S3AsyncClient.
- returns
An instance of S3
- Annotations
- @UnsafeBecauseImpure()
- See also
S3.fromConfig and S3.create for a pure implementation. They both will make sure that the s3 connection is created with the required resources and guarantee that the client was not previously closed.
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def fromConfig(monixAwsConf: Task[MonixAwsConf]): Resource[Task, S3]
Provides a resource that uses the values from the config file to acquire and release a S3 instance.
Provides a resource that uses the values from the config file to acquire and release a S3 instance.
The config will come from MonixAwsConf which it is actually obtained from the
application.conf
file present under theresources
folder.Example
import monix.connect.aws.auth.MonixAwsConf import monix.eval.Task import monix.connect.s3.S3 val awsConf: Task[MonixAwsConf] = MonixAwsConf.load() S3.fromConfig(awsConf).use { s3 => //business logic here Task.unit }
- monixAwsConf
a task containing the monix aws config read from config file.
- returns
a Resource of Task that acquires and releases S3.
- def fromConfig(monixAwsConf: MonixAwsConf): Resource[Task, S3]
Provides a resource that uses the values from the config file to acquire and release a S3 instance.
Provides a resource that uses the values from the config file to acquire and release a S3 instance.
The config will come from MonixAwsConf which it is actually obtained from the
application.conf
file present under theresources
folder.Example
import monix.connect.aws.auth.MonixAwsConf import monix.connect.s3.S3 import monix.eval.Task import software.amazon.awssdk.regions.Region MonixAwsConf.load().flatMap{ awsConf => // you can update your config from code too val updatedAwsConf = awsConf.copy(region = Region.AP_SOUTH_1) S3.fromConfig(updatedAwsConf).use { s3 => //business logic here Task.unit } }
- monixAwsConf
the monix aws config read from config file.
- returns
a Resource of Task that acquires and releases S3.
- def fromConfig(namingConvention: NamingConvention = KebabCase): Resource[Task, S3]
Provides a resource that uses the values from the config file to acquire and release a S3 instance.
Provides a resource that uses the values from the config file to acquire and release a S3 instance.
It does not requires any input parameter as it expect the aws config to be set from
application.conf
, which has to be placed under theresources
folder and will overwrite the defaults values from:https://github.com/monix/monix-connect/blob/master/aws-auth/src/main/resources/reference.conf
.Example
import monix.connect.aws.auth.MonixAwsConf import monix.connect.s3.S3 import monix.eval.Task S3.fromConfig.use { s3 => //business logic here Task.unit }
- returns
a Resource of Task that acquires and releases S3.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
Deprecated Value Members
- def copyObject(request: CopyObjectRequest)(implicit s3AsyncClient: S3AsyncClient): Task[CopyObjectResponse]
- Annotations
- @deprecated
- Deprecated
(Since version 0.5.0) Use one of the builders like
S3.create
- def copyObject(sourceBucket: String, sourceKey: String, destinationBucket: String, destinationKey: String, copyObjectSettings: CopyObjectSettings = DefaultCopyObjectSettings)(implicit s3AsyncClient: S3AsyncClient): Task[CopyObjectResponse]
- Annotations
- @deprecated
- Deprecated
(Since version 0.5.0) Use one of the builders like
S3.create
- def createBucket(request: CreateBucketRequest)(implicit s3AsyncClient: S3AsyncClient): Task[CreateBucketResponse]
- Annotations
- @deprecated
- Deprecated
(Since version 0.5.0) Use one of the builders like
S3.create
- def createBucket(bucket: String, acl: Option[BucketCannedACL] = None, grantFullControl: Option[String] = None, grantRead: Option[String] = None, grantReadACP: Option[String] = None, grantWrite: Option[String] = None, grantWriteACP: Option[String] = None, objectLockEnabledForBucket: Option[Boolean] = None)(implicit s3AsyncClient: S3AsyncClient): Task[CreateBucketResponse]
- Annotations
- @deprecated
- Deprecated
(Since version 0.5.0) Use one of the builders like
S3.create
- def deleteBucket(request: DeleteBucketRequest)(implicit s3AsyncClient: S3AsyncClient): Task[DeleteBucketResponse]
- Annotations
- @deprecated
- Deprecated
(Since version 0.5.0) Use one of the builders like
S3.create
- def deleteBucket(bucket: String)(implicit s3AsyncClient: S3AsyncClient): Task[DeleteBucketResponse]
- Annotations
- @deprecated
- Deprecated
(Since version 0.5.0) Use one of the builders like
S3.create
- def deleteObject(request: DeleteObjectRequest)(implicit s3AsyncClient: S3AsyncClient): Task[DeleteObjectResponse]
- Annotations
- @deprecated
- Deprecated
(Since version 0.5.0) Use one of the builders like
S3.create
- def deleteObject(bucket: String, key: String, bypassGovernanceRetention: Option[Boolean] = None, mfa: Option[String] = None, requestPayer: Option[String] = None, versionId: Option[String] = None)(implicit s3AsyncClient: S3AsyncClient): Task[DeleteObjectResponse]
- Annotations
- @deprecated
- Deprecated
(Since version 0.5.0) Use one of the builders like
S3.create
- def download(request: GetObjectRequest)(implicit s3AsyncClient: S3AsyncClient): Task[Array[Byte]]
- Annotations
- @deprecated
- Deprecated
(Since version 0.5.0) Use one of the builders like
S3.create
- def download(bucket: String, key: String, firstNBytes: Option[Int] = None, downloadSettings: DownloadSettings = DefaultDownloadSettings)(implicit s3AsyncClient: S3AsyncClient): Task[Array[Byte]]
- Annotations
- @deprecated
- Deprecated
(Since version 0.5.0) Use one of the builders like
S3.create
- def downloadMultipart(bucket: String, key: String, chunkSize: Long = domain.awsMinChunkSize, downloadSettings: DownloadSettings = DefaultDownloadSettings)(implicit s3AsyncClient: S3AsyncClient): Observable[Array[Byte]]
- Annotations
- @deprecated
- Deprecated
(Since version 0.5.0) Use one of the builders like
S3.create
- def existsBucket(bucket: String)(implicit s3AsyncClient: S3AsyncClient): Task[Boolean]
- Annotations
- @deprecated
- Deprecated
(Since version 0.5.0) Use one of the builders like
S3.create
- def existsObject(bucket: String, key: String)(implicit s3AsyncClient: S3AsyncClient): Task[Boolean]
- Annotations
- @deprecated
- Deprecated
(Since version 0.5.0) Use one of the builders like
S3.create
- def fromConfig: Resource[Task, S3]
Provides a resource that uses the values from the config file to acquire and release a S3 instance.
Provides a resource that uses the values from the config file to acquire and release a S3 instance.
It does not requires any input parameter as it expect the aws config to be set from
application.conf
, which has to be placed under theresources
folder and will overwrite the defaults values from:https://github.com/monix/monix-connect/blob/master/aws-auth/src/main/resources/reference.conf
.Example
import monix.connect.aws.auth.MonixAwsConf import monix.connect.s3.S3 import monix.eval.Task S3.fromConfig.use { s3 => //business logic here Task.unit }
- returns
a Resource of Task that acquires and releases S3.
- Annotations
- @deprecated
- Deprecated
(Since version 0.6.1) Use
fromConfig(namingConvention)
- def listBuckets()(implicit s3AsyncClient: S3AsyncClient): Observable[Bucket]
- Annotations
- @deprecated
- Deprecated
(Since version 0.5.0) Use one of the builders like
S3.create
- def listObjects(bucket: String, prefix: Option[String] = None, maxTotalKeys: Option[Int] = None, requestPayer: Option[RequestPayer] = None)(implicit s3AsyncClient: S3AsyncClient): Observable[S3Object]
- Annotations
- @deprecated
- Deprecated
(Since version 0.5.0) Use one of the builders like
S3.create
- def upload(request: PutObjectRequest, content: Array[Byte])(implicit s3AsyncClient: S3AsyncClient): Task[PutObjectResponse]
- Annotations
- @deprecated
- Deprecated
(Since version 0.5.0) Use one of the builders like
S3.create
- def upload(bucket: String, key: String, content: Array[Byte], uploadSettings: UploadSettings = DefaultUploadSettings)(implicit s3AsyncClient: S3AsyncClient): Task[PutObjectResponse]
- Annotations
- @deprecated
- Deprecated
(Since version 0.5.0) Use one of the builders like
S3.create
- def uploadMultipart(bucket: String, key: String, minChunkSize: Int = awsMinChunkSize, uploadSettings: UploadSettings = DefaultUploadSettings)(implicit s3AsyncClient: S3AsyncClient): Consumer[Array[Byte], CompleteMultipartUploadResponse]
- Annotations
- @deprecated
- Deprecated
(Since version 0.5.0) Use one of the builders like
S3.create