S3

This store is used to interface with AWS S3. Head over to the official documentation for the Java client for details on how to configure it. Here in an example using access- and secret keys.

import blobstore.s3.{S3Store, S3MetaInfo}
import blobstore.url.Url
import cats.effect.Async

import software.amazon.awssdk.auth.credentials.{AwsBasicCredentials, StaticCredentialsProvider}
import software.amazon.awssdk.regions.Region
import software.amazon.awssdk.services.s3.S3AsyncClient

def createS3[F[_]: Async]: S3Store[F] = {
  val client: S3AsyncClient = S3AsyncClient
    .builder()
    .region(Region.US_EAST_1)
    .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("access_key", "secret_key")))
    .build()
  
  S3Store.builder[F](client).unsafe
}

Creation of the S3 client is effectful due to input parameter validation. The generic API makes no assumptions on the type of the underlying object. If you want to use S3 specific features such as server side encryption, object versions or ACLs, you can find S3 specific APIs in S3Store[F] that allows that. Here is an example for SSE

def s3SseGet[F[_]](s3: S3Store[F], url: Url.Plain, sseKey: String): fs2.Stream[F, Byte] = 
    s3.get(url, S3MetaInfo.const(constSseCustomerKey = Some(sseKey)))