Packages

trait S3 extends AnyRef

Represents the Monix S3 client which can be created using the builders from its companion object.

Self Type
S3
Source
S3.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. S3
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  6. def close: Task[Unit]

    Closes the underlying S3AsyncClient.

  7. def copyObject(request: CopyObjectRequest): Task[CopyObjectResponse]

    Creates a copy from an already stored object.

    Creates a copy from an already stored object.

    request

    the CopyObjectRequest.

    returns

    a Task containing the result of the CopyObject operation returned by the service.

  8. def copyObject(sourceBucket: String, sourceKey: String, destinationBucket: String, destinationKey: String, copyObjectSettings: CopyObjectSettings = DefaultCopyObjectSettings): Task[CopyObjectResponse]

    Creates a copy of from an already stored object.

    Creates a copy of from an already stored object.

    Example

    val sourceBucket = "source-bucket"
    val sourceKey = "source/key.json"
    val targetBucket = "target-bucket"
    val targetKey = "target/key.json"
    val t = S3.fromConfig.use(_.copyObject(sourceBucket, sourceKey, targetBucket, targetKey))
    sourceBucket

    the name of the source bucket.

    sourceKey

    the key of the source object.

    destinationBucket

    the name of the destination bucket.

    destinationKey

    the key of the destination object.

    copyObjectSettings

    adds the CopyObjectSettings on the request copy object request.

    returns

    a Task containing the result of the CopyObject operation returned by the service.

  9. def createBucket(request: CreateBucketRequest): Task[CreateBucketResponse]

    Creates a bucket given a CreateBucketRequest.

    Creates a bucket given a CreateBucketRequest.

    request

    an instance of CreateBucketRequest

    returns

    a Task with the create bucket response CreateBucketResponse .

    See also

    https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/s3/model/CreateBucketRequest.Builder.html

  10. 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): Task[CreateBucketResponse]

    Creates a bucket.

    Creates a bucket.

    Example

    import monix.eval.Task
    import monix.connect.s3.S3
    import software.amazon.awssdk.services.s3.model.CreateBucketResponse
    
    val bucket = "my-bucket"
    val t: Task[CreateBucketResponse] = S3.fromConfig.use(_.createBucket(bucket))
    bucket

    the name of the bucket to be created.

    acl

    the canned ACL (Access Control List) to apply to the object. if the service returns an enum value that is not available in the current SDK version, acl will return ObjectCannedACL.UNKNOWN_TO_SDK_VERSION.

    grantFullControl

    gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object.

    grantRead

    allows grantee to read the object data and its metadata.

    grantReadACP

    allows grantee to read the object ACL.

    grantWriteACP

    allows grantee to write the ACL for the applicable object.

    objectLockEnabledForBucket

    specifies whether you want S3 Object Lock to be enabled for the new bucket.

    returns

    a Task with the CreateBucketResponse.

    See also

    https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/s3/model/CreateBucketRequest.Builder.html

  11. def deleteBucket(request: DeleteBucketRequest): Task[DeleteBucketResponse]

    Deletes the specified bucket.

    Deletes the specified bucket. Which will only happen when it is empty.

    request

    the AWS delete bucket request of type DeleteBucketRequest

    returns

    a Task with the delete bucket response DeleteBucketResponse .

    Note

    When attempting to delete a bucket that does not exist, Amazon S3 returns a success message, not an error message.

    See also

    https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/s3/model/DeleteBucketRequest.html

  12. def deleteBucket(bucket: String): Task[DeleteBucketResponse]

    Deletes the specified bucket.

    Deletes the specified bucket. Which will only happen when it is empty.

    bucket

    the bucket name to be deleted.

    returns

    a Task with the delete bucket response DeleteBucketResponse .

    Note

    When attempting to delete a bucket that does not exist, Amazon S3 returns a success message, not an error message.

    See also

    https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/s3/model/DeleteBucketRequest.html

  13. def deleteObject(request: DeleteObjectRequest): Task[DeleteObjectResponse]

    Deletes the specified object given a DeleteBucketRequest.

    Deletes the specified object given a DeleteBucketRequest. Once deleted, the object can only be restored if versioning was enabled when the object was deleted.

    request

    the AWS delete object request of type DeleteObjectRequest

    returns

    a Task with the delete object response DeleteObjectResponse .

    See also

    https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/s3/model/DeleteObjectRequest.html

  14. def deleteObject(bucket: String, key: String, bypassGovernanceRetention: Option[Boolean] = None, mfa: Option[String] = None, requestPayer: Option[String] = None, versionId: Option[String] = None): Task[DeleteObjectResponse]

    Deletes the specified object.

    Deletes the specified object. Once deleted, the object can only be restored if versioning was enabled when the object was deleted.

    bucket

    the bucket name of the object to be deleted.

    key

    the key of the object to be deleted.

    bypassGovernanceRetention

    Indicates whether S3 Object Lock should bypass Governance-mode restrictions to process this operation.

    mfa

    the concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device. Required to permanently delete a versioned object if versioning is configured with MFA delete enabled.

    requestPayer

    sets the value of the RequestPayer property for this object.

    versionId

    versionId used to reference a specific version of the object.

    returns

    a Task with the delete object response DeleteObjectResponse .

    Note

    Once deleted, the object can only be restored if versioning was enabled when the object was deleted.

    See also

    https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/s3/model/DeleteObjectRequest.html

  15. def download(request: GetObjectRequest): Task[Array[Byte]]

    Downloads an object as byte array.

    Downloads an object as byte array.

    request

    the AWS get object request of type GetObjectRequest.

    returns

    A Task that contains the downloaded object as a byte array.

    Annotations
    @Unsafe("OOM risk, use `downloadMultipart` for big downloads.")
    See also

    https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/s3/model/GetObjectRequest.html

  16. def download(bucket: String, key: String, firstNBytes: Option[Int] = None, downloadSettings: DownloadSettings = DefaultDownloadSettings): Task[Array[Byte]]

    Downloads an object in a single request as byte array.

    Downloads an object in a single request as byte array.

    The only two required fields are the bucket and key, but it also accepts additional settings for more specific requests, see DownloadSettings.

    WARN! - This method is only suitable for downloading small objects, since it performs a single download request, which might be unsafe when the object is too big to fit in memory or in the http body.

    bucket

    target S3 bucket name of the object to be downloaded.

    key

    key of the object to be downloaded.

    firstNBytes

    downloads the first firstNBytes from the specified object, it must be a positive number if defined.

    downloadSettings

    additional settings to pass to the download object request.

    returns

    a Task containing the downloaded object as a byte array.

    Annotations
    @Unsafe("OOM risk, use `downloadMultipart` for big downloads.")
    See also

    the safer alternative downloadMultipart to for downloading objects in parts.

    Example

    import monix.eval.Task
    import monix.connect.s3.S3
    import cats.effect.Resource
    
    val s3Resource: Resource[Task, S3] = S3.fromConfig // alternatively use `create`
    
    val bucket: String = "sample-bucket"
    val key: String = "path/to/test.csv"
    
    // only downloads the first 100 bytes of the object
    val t: Task[Array[Byte]] = s3Resource.use(_.download(bucket, key, firstNBytes = Some(100)))

    Unsafe Example

    import monix.eval.Task
    import software.amazon.awssdk.services.s3.S3AsyncClient
    import software.amazon.awssdk.regions.Region.AWS_GLOBAL
    import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider
    
    // must be properly configured
    val s3AsyncClient = S3AsyncClient.builder
      .credentialsProvider(DefaultCredentialsProvider.create())
      .region(AWS_GLOBAL)
      .build()
    
    val s3: S3 = S3.createUnsafe(s3AsyncClient)
    
    // only downloads the first 100 bytes of the object
    val arr: Task[Array[Byte]] = s3.download(bucket, key, firstNBytes = Some(100))

    https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/mediastoredata/model/GetObjectRequest.html

  17. def downloadMultipart(bucket: String, key: String, chunkSize: Long = domain.awsMinChunkSize, downloadSettings: DownloadSettings = DefaultDownloadSettings): Observable[Array[Byte]]

    Safely downloads objects of any size by performing partial download requests.

    Safely downloads objects of any size by performing partial download requests. The number of bytes to download per each request is specified by the chunkSize.

    Example

    import monix.reactive.Observable
    import monix.eval.Task
    import monix.connect.s3.S3
    import cats.effect.Resource
    import monix.reactive.Consumer
    val s3Resource: Resource[Task, S3] = S3.fromConfig
    val bucket: String = "sample-bucket"
    val key: String = "sample-key"
    
    val t = s3Resource.use { s3 =>
      val ob: Observable[Array[Byte]] = s3.downloadMultipart(bucket, key, 2)
      // do your business logic
      ob.consumeWith(Consumer.complete) // mere sample
     }

    Unsafe Example

    import monix.reactive.Observable
    import software.amazon.awssdk.services.s3.S3AsyncClient
    import software.amazon.awssdk.regions.Region.AWS_GLOBAL
    import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider
    
    // must be properly configured
    val client = S3AsyncClient.builder
      .credentialsProvider(DefaultCredentialsProvider.create())
      .region(AWS_GLOBAL)
      .build()
    
    val ob: Observable[Array[Byte]] = S3.createUnsafe(client).downloadMultipart(bucket, key, 2)
    bucket

    target S3 bucket name of the object to be downloaded.

    key

    path of the object to be downloaded (excluding the bucket).

    chunkSize

    amount of bytes to downloaded for each part request, must be a positive number, being by default (recommended) 5242880 bytes.

    downloadSettings

    additional settings to pass to the multipart download request.

    returns

    an Observable that emits chunks of bytes of size chunkSize until it completes. in case the object does not exists an Array.emptyByteArray is returned, whereas if the bucket does not exists it return a failed Task of software.amazon.awssdk.services.s3.model.NoSuchBucketException.

  18. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  19. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  20. def existsBucket(bucket: String): Task[Boolean]

    Check whether the specified bucket exists or not.

    Check whether the specified bucket exists or not.

    bucket

    the bucket name to check its existence

    returns

    a boolean Task indicating whether the bucket exists or not.

  21. def existsObject(bucket: String, key: String): Task[Boolean]

    Checks whether the specified object exists or not.

    Checks whether the specified object exists or not.

    Example

    import monix.eval.Task
    import monix.connect.s3.S3
    
    val bucket = "my-bucket"
    val s3Key = "my-key"
    
    val t: Task[Boolean] = S3.fromConfig.use(_.existsObject(bucket, s3Key))
    bucket

    the bucket name of the object to check its existence.

    key

    the key of the object to be deleted.

    returns

    a boolean Task indicating whether the object existed or not.

  22. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  23. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  24. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  25. def headObject(bucket: String, key: String): Task[HeadObjectResponse]

    The head action retrieves metadata from an object without returning the object itself.

    The head action retrieves metadata from an object without returning the object itself.

    bucket

    the bucket in which to search the object

    key

    scope for object to retreive the metadata from

    returns

    response from the head object as HeadObjectResponse

  26. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  27. def listBuckets(): Observable[Bucket]

    Lists all of the buckets owned by the authenticated sender of the request.

    Lists all of the buckets owned by the authenticated sender of the request.

    Example

    import monix.reactive.Consumer
    import monix.reactive.Observable
    import monix.eval.Task
    import cats.effect.Resource
    import software.amazon.awssdk.services.s3.model.Bucket
    
    val s3Resource: Resource[Task, S3] = S3.fromConfig
    val bucket: String = "sample-bucket"
    val key: String = "sample-key"
    
    val t = s3Resource.use { s3 =>
      val buckets: Observable[Bucket] = s3.listBuckets()
      // your business logic here
      buckets.consumeWith(Consumer.complete) // mere example
    }

    Unsafe Example

    import monix.reactive.Observable
    import software.amazon.awssdk.services.s3.S3AsyncClient
    import software.amazon.awssdk.regions.Region.AWS_GLOBAL
    import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider
    import software.amazon.awssdk.services.s3.model.Bucket
    
    // must be propelry configured
    val s3AsyncClient = S3AsyncClient.builder
      .credentialsProvider(DefaultCredentialsProvider.create())
      .region(AWS_GLOBAL)
      .build()
    
    val buckets: Observable[Bucket] =  S3.createUnsafe(s3AsyncClient).listBuckets()
    returns

    an Observable that emits the list of existing Buckets.

  28. def listLatestNObjects(bucket: String, n: Int, prefix: Option[String] = None, requestPayer: Option[RequestPayer] = None): Observable[S3Object]

    Returns latest N objects in bucket.

    Returns latest N objects in bucket.

    Example

    import cats.effect.Resource
    import monix.connect.s3.S3
    import monix.eval.Task
    import software.amazon.awssdk.auth.credentials.{AwsBasicCredentials, StaticCredentialsProvider}
    import software.amazon.awssdk.regions.Region
    import monix.execution.Scheduler.Implicits.global
    
    val bucket = "my-bucket"
    val prefix = "prefix/to/list/keys"
    val s3AccessKey: String = "TESTKEY"
    val s3SecretKey: String = "TESTSECRET"
    val basicAWSCredentials = AwsBasicCredentials.create(s3AccessKey, s3SecretKey)
    val staticCredProvider = StaticCredentialsProvider.create(basicAWSCredentials)
    
    val s3: Resource[Task, S3] = S3.create(staticCredProvider, Region.AWS_GLOBAL)
    
    s3.use{s3 => s3.listLatestNObjects(bucket, 6, prefix = Some(prefix)).toListL}.runToFuture
    bucket

    target S3 bucket name of the object to be downloaded.

    prefix

    limits the response to keys that begin with the specified prefix.

    requestPayer

    confirms that the requester knows that she or he will be charged for the list objects request in V2 style. Bucket owners need not specify this parameter in their requests.

    returns

    an Observable that emits the S3Objects.

    Note

    To use this operation in an AWS (IAM) policy, you must have permissions to perform the ListBucket action. The bucket owner has this permission by default and can grant it.

  29. def listLatestObject(bucket: String, prefix: Option[String] = None, requestPayer: Option[RequestPayer] = None): Task[Option[S3Object]]

    Returns the most recently uploaded object in a bucket.

    Returns the most recently uploaded object in a bucket.

    Example

    import cats.effect.Resource
    import monix.connect.s3.S3
    import monix.eval.Task
    import software.amazon.awssdk.auth.credentials.{AwsBasicCredentials, StaticCredentialsProvider}
    import software.amazon.awssdk.regions.Region
    import monix.execution.Scheduler.Implicits.global
    
    val bucket = "my-bucket"
    val prefix = "prefix/to/list/keys"
    val s3AccessKey: String = "TESTKEY"
    val s3SecretKey: String = "TESTSECRET"
    val basicAWSCredentials = AwsBasicCredentials.create(s3AccessKey, s3SecretKey)
    val staticCredProvider = StaticCredentialsProvider.create(basicAWSCredentials)
    
    val s3: Resource[Task, S3] = S3.create(staticCredProvider, Region.AWS_GLOBAL)
    
    s3.use{s3 => s3.listLatestObject(bucket, prefix = Some(prefix))}.runToFuture
    bucket

    target S3 bucket name of the object to be downloaded.

    prefix

    limits the response to keys that begin with the specified prefix.

    requestPayer

    confirms that the requester knows that she or he will be charged for the list objects request in V2 style. Bucket owners need not specify this parameter in their requests.

    returns

    an Task that emits the Option[S3Object]s.

    Note

    To use this operation in an AWS (IAM) policy, you must have permissions to perform the ListBucket action. The bucket owner has this permission by default and can grant it.

  30. def listObjects(bucket: String, prefix: Option[String] = None, maxTotalKeys: Option[Int] = None, requestPayer: Option[RequestPayer] = None): Observable[S3Object]

    Returns some or all of the objects in a bucket.

    Returns some or all of the objects in a bucket. You can use the request parameters as selection criteria to return a subset of the objects in a bucket.

    Example

    import monix.reactive.Consumer
    import monix.reactive.Observable
    import monix.eval.Task
    import cats.effect.Resource
    import software.amazon.awssdk.services.s3.model.S3Object
    
    val s3Resource: Resource[Task, S3] = S3.fromConfig
    val bucket = "my-bucket"
    val prefix = "prefix/to/list/keys/"
    
    val t = s3Resource.use { s3 =>
      val s3Objects: Observable[S3Object] =
          s3.listObjects(bucket, maxTotalKeys = Some(1011), prefix = Some(prefix))
       //your business logic here
       s3Objects.consumeWith(Consumer.complete) //mere example
    }

    Unsafe Example

    import monix.reactive.Observable
    import software.amazon.awssdk.services.s3.S3AsyncClient
    import software.amazon.awssdk.regions.Region.AWS_GLOBAL
    import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider
    import software.amazon.awssdk.services.s3.model.S3Object
    
    // must be properly configured
    val s3AsyncClient = S3AsyncClient.builder
      .credentialsProvider(DefaultCredentialsProvider.create())
      .region(AWS_GLOBAL)
      .build()
    
    val s3: S3 = S3.createUnsafe(s3AsyncClient)
    
    val s3Objects: Observable[S3Object] = s3.listObjects(bucket, maxTotalKeys = Some(1011), prefix = Some(prefix))
    bucket

    target S3 bucket name of the object to be downloaded.

    prefix

    limits the response to keys that begin with the specified prefix.

    maxTotalKeys

    sets the maximum number of keys to be list, it must be a positive number.

    requestPayer

    confirms that the requester knows that she or he will be charged for the list objects request in V2 style. Bucket owners need not specify this parameter in their requests.

    returns

    an Observable that emits the S3Objects.

    Note

    To use this operation in an AWS (IAM) policy, you must have permissions to perform the ListBucket action. The bucket owner has this permission by default and can grant it.

  31. def listOldestNObjects(bucket: String, n: Int, prefix: Option[String] = None, requestPayer: Option[RequestPayer] = None): Observable[S3Object]

    Returns oldest N objects in bucket.

    Returns oldest N objects in bucket.

    Example

    import cats.effect.Resource
    import monix.connect.s3.S3
    import monix.eval.Task
    import software.amazon.awssdk.auth.credentials.{AwsBasicCredentials, StaticCredentialsProvider}
    import software.amazon.awssdk.regions.Region
    import monix.execution.Scheduler.Implicits.global
    
    val bucket = "my-bucket"
    val prefix = "prefix/to/list/keys"
    val s3AccessKey: String = "TESTKEY"
    val s3SecretKey: String = "TESTSECRET"
    val basicAWSCredentials = AwsBasicCredentials.create(s3AccessKey, s3SecretKey)
    val staticCredProvider = StaticCredentialsProvider.create(basicAWSCredentials)
    
    val s3: Resource[Task, S3] = S3.create(staticCredProvider, Region.AWS_GLOBAL)
    
    s3.use{s3 => s3.listOldestNObjects(bucket, 6, prefix = Some(prefix)).toListL}.runToFuture
    bucket

    target S3 bucket name of the object to be downloaded.

    prefix

    limits the response to keys that begin with the specified prefix.

    requestPayer

    confirms that the requester knows that she or he will be charged for the list objects request in V2 style. Bucket owners need not specify this parameter in their requests.

    returns

    an Observable that emits the S3Objects.

    Note

    To use this operation in an AWS (IAM) policy, you must have permissions to perform the ListBucket action. The bucket owner has this permission by default and can grant it.

  32. def listOldestObject(bucket: String, prefix: Option[String] = None, requestPayer: Option[RequestPayer] = None): Task[Option[S3Object]]

    Returns the most oldest uploaded object in a bucket.

    Returns the most oldest uploaded object in a bucket.

    Example

    import cats.effect.Resource
    import monix.connect.s3.S3
    import monix.eval.Task
    import software.amazon.awssdk.auth.credentials.{AwsBasicCredentials, StaticCredentialsProvider}
    import software.amazon.awssdk.regions.Region
    import monix.execution.Scheduler.Implicits.global
    
    val bucket = "my-bucket"
    val prefix = "prefix/to/list/keys"
    val s3AccessKey: String = "TESTKEY"
    val s3SecretKey: String = "TESTSECRET"
    val basicAWSCredentials = AwsBasicCredentials.create(s3AccessKey, s3SecretKey)
    val staticCredProvider = StaticCredentialsProvider.create(basicAWSCredentials)
    
    val s3: Resource[Task, S3] = S3.create(staticCredProvider, Region.AWS_GLOBAL)
    
    s3.use{s3 => s3.listOldestObject(bucket, prefix = Some(prefix))}.runToFuture
    bucket

    target S3 bucket name of the object to be downloaded.

    prefix

    limits the response to keys that begin with the specified prefix.

    requestPayer

    confirms that the requester knows that she or he will be charged for the list objects request in V2 style. Bucket owners need not specify this parameter in their requests.

    returns

    an Task that emits the Option[S3Object]s.

    Note

    To use this operation in an AWS (IAM) policy, you must have permissions to perform the ListBucket action. The bucket owner has this permission by default and can grant it.

  33. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  34. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  35. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  36. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  37. def toString(): String
    Definition Classes
    AnyRef → Any
  38. def upload(request: PutObjectRequest, content: Array[Byte]): Task[PutObjectResponse]

    Uploads a new object to the specified Amazon S3 bucket.

    Uploads a new object to the specified Amazon S3 bucket.

    request

    instance of PutObjectRequest

    content

    content to be uploaded

    returns

    the response from the http put object request as PutObjectResponse.

    See also

    https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/s3/model/PutObjectRequest.html

  39. def upload(bucket: String, key: String, content: Array[Byte], uploadSettings: UploadSettings = DefaultUploadSettings): Task[PutObjectResponse]

    Uploads a new object to the specified Amazon S3 bucket.

    Uploads a new object to the specified Amazon S3 bucket.

    Example

    import monix.eval.Task
    import cats.effect.Resource
    
    val s3Resource: Resource[Task, S3] = S3.fromConfig
    val bucket: String = "sample-bucket"
    val key: String = "sample/s3/object"
    val content: Array[Byte] = "Whatever your content is".getBytes()
    
    val t = s3Resource.use(_.upload(bucket, key, content))

    Unsafe Example

    import monix.eval.Task
    import monix.connect.s3.S3
    import software.amazon.awssdk.services.s3.S3AsyncClient
    import software.amazon.awssdk.regions.Region.AWS_GLOBAL
    import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider
    
    // must be properly configured
    val s3AsyncClient = S3AsyncClient.builder
      .credentialsProvider(DefaultCredentialsProvider.create())
      .region(AWS_GLOBAL)
      .build()
    
    val s3: S3 = S3.createUnsafe(s3AsyncClient)
    
    val response = s3.upload(bucket, key, content)
    bucket

    the bucket where this request will upload a new object to

    key

    key under which to store the new object

    content

    text content to be uploaded

    returns

    response from the put object http request as PutObjectResponse

  40. def uploadMultipart(bucket: String, key: String, minChunkSize: Int = awsMinChunkSize, uploadSettings: UploadSettings = DefaultUploadSettings): Consumer[Array[Byte], CompleteMultipartUploadResponse]

    Uploads an S3 object by making multiple http requests (parts) of the received chunks of bytes.

    Uploads an S3 object by making multiple http requests (parts) of the received chunks of bytes.

    Example

    import monix.reactive.Observable
    import monix.eval.Task
    import cats.effect.Resource
    
    val s3Resource: Resource[Task, S3] = S3.fromConfig
    val bucket: String = "sample-bucket"
    val key: String = "sample/key/to/s3/object"
    val content: Array[Byte] = "Hello World!".getBytes
    
    val t = s3Resource.use { s3 =>
      Observable.pure(content).consumeWith(s3.uploadMultipart(bucket, key))
    }

    Unsafe Example

    import monix.reactive.Observable
    import monix.connect.s3.S3
    import software.amazon.awssdk.services.s3.S3AsyncClient
    import software.amazon.awssdk.regions.Region.AWS_GLOBAL
    import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider
    
    // must be properly configured
    val s3AsyncClient = S3AsyncClient.builder
      .credentialsProvider(DefaultCredentialsProvider.create())
      .region(AWS_GLOBAL)
      .build()
    
    val s3: S3 = S3.createUnsafe(s3AsyncClient)
    
    val response = Observable.pure(content).consumeWith(s3.uploadMultipart(bucket, key))
    bucket

    the bucket name where the object will be stored

    key

    the key where the object will be stored.

    minChunkSize

    size of the chunks (parts) that will be sent in the http body. (the minimum size is set by default, don't use a lower one)

    returns

    the confirmation of the multipart whole upload as CompleteMultipartUploadResponse.

  41. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  42. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  43. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped