← ZIO S3 docs

S3

zio.s3.S3
trait S3

The S3 module provides access to a s3 amazon storage. All operations are async since we are relying on the amazon async client

Attributes

Source
S3.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Live
Self type
S3

Members list

Value members

Abstract methods

def createBucket(bucketName: String): IO[S3Exception, Unit]

Create a bucket

Create a bucket

Value parameters

bucketName

name of the bucket

Attributes

Source
S3.scala
def deleteBucket(bucketName: String): IO[S3Exception, Unit]

Delete bucket, the operation fail if bucket is not present

Delete bucket, the operation fail if bucket is not present

Value parameters

bucketName

name of the bucket

Attributes

Source
S3.scala
def deleteObject(bucketName: String, key: String): IO[S3Exception, Unit]

delete an object from a bucket, if not present it will succeed

delete an object from a bucket, if not present it will succeed

Value parameters

bucketName

name of the bucket

key

object identifier to remove

Attributes

Source
S3.scala
def execute[T](f: S3AsyncClient => CompletableFuture[T]): IO[S3Exception, T]

expose safely amazon s3 async client

expose safely amazon s3 async client

Type parameters

T

value type to return

Value parameters

f

call any operations on s3 async client

Attributes

Source
S3.scala
def getNextObjects(listing: S3ObjectListing): IO[S3Exception, S3ObjectListing]

Fetch the next object listing from a specific object listing.

Fetch the next object listing from a specific object listing.

Value parameters

listing

listing to use as a start

Attributes

Source
S3.scala
def getObject(bucketName: String, key: String): Stream[S3Exception, Byte]

Read an object from a bucket, the operation fail if object is not present

Read an object from a bucket, the operation fail if object is not present

Value parameters

bucketName

name of the bucket

key

object identifier to read

Attributes

Source
S3.scala
def getObjectMetadata(bucketName: String, key: String): IO[S3Exception, ObjectMetadata]

Retrieves metadata from an object without returning the object itself. This operation is useful if you're only interested in an object's metadata.

Retrieves metadata from an object without returning the object itself. This operation is useful if you're only interested in an object's metadata.

Value parameters

bucketName

name of the bucket

key

object identifier to read

Attributes

Returns

the ObjectMetadata

Source
S3.scala
def isBucketExists(bucketName: String): IO[S3Exception, Boolean]

Check if bucket exists

Check if bucket exists

Value parameters

bucketName

name of the bucket

Attributes

Source
S3.scala
def listObjects(bucketName: String, options: ListObjectOptions): IO[S3Exception, S3ObjectListing]

Attributes

Source
S3.scala
def multipartUpload[R](bucketName: String, key: String, content: ZStream[R, Throwable, Byte], options: MultipartUploadOptions = ...)(parallelism: Int): ZIO[R, S3Exception, Unit]

Store data object into a specific bucket, minimum size of the data is 5 Mb to use multipart upload (restriction from amazon API)

Store data object into a specific bucket, minimum size of the data is 5 Mb to use multipart upload (restriction from amazon API)

Value parameters

bucketName

name of the bucket

content

object data

key

unique object identifier

options

the optional configurations of the multipart upload

parallelism

the number of parallel requests to upload chunks

Attributes

Source
S3.scala
def putObject[R](bucketName: String, key: String, contentLength: Long, content: ZStream[R, Throwable, Byte], options: UploadOptions = ..., contentMD5: Option[String] = ...): ZIO[R, S3Exception, Unit]

Store data object into a specific bucket

Store data object into a specific bucket

==Example of creating a contentMD5 option==

The md5 option is required when the target bucket is configured with object locking, otherwise the AWS S3 API will not accept the putObject request.

import software.amazon.awssdk.utils.Md5Utils
import scala.util.Random

val bytes  = Random.nextString(65536).getBytes()
val contentMD5 = Some(Md5Utils.md5AsBase64(bytes))

Value parameters

bucketName

name of the bucket

content

object data

contentLength

length of the data in bytes

contentMD5

a String Option containing the MD5 hash of the content encoded as base64

key

unique object identifier

Attributes

Source
S3.scala

Concrete methods

def listAllObjects(bucketName: String): Stream[S3Exception, S3ObjectSummary]

List all descendant objects of a bucket Fetch all objects recursively of all nested directory by traversing all of them

List all descendant objects of a bucket Fetch all objects recursively of all nested directory by traversing all of them

Value parameters

bucketName

name of the bucket MaxKeys have a default value to 1000 elements

Attributes

Source
S3.scala
def listAllObjects(bucketName: String, options: ListObjectOptions): Stream[S3Exception, S3ObjectSummary]

Attributes

Source
S3.scala
def listObjects(bucketName: String): IO[S3Exception, S3ObjectListing]

list all object for a specific bucket

list all object for a specific bucket

Value parameters

bucketName

name of the bucket

Attributes

Source
S3.scala
def paginate(initialListing: S3ObjectListing): Stream[S3Exception, S3ObjectListing]

List all objects by traversing all nested directories

List all objects by traversing all nested directories

Value parameters

initialListing

object listing to start with

Attributes

Source
S3.scala
def streamLines(bucketName: String, key: String): Stream[S3Exception, String]

Read an object by lines

Read an object by lines

Value parameters

bucketName

name of the bucket

key:

unique key of the object

Attributes

Source
S3.scala

Abstract fields

val listBuckets: IO[S3Exception, S3BucketListing]

List all available buckets

List all available buckets

Attributes

Source
S3.scala