compile "com.avast.clients.storage:storage-client-gcs_2.13:x.x.x"
projectId = "my-project-id"
bucketName = "bucket-name"
GCS backends supports multiple ways of authentication:
- Providing path to the credentials file in the configuration under
credentialsFile
key - Using
GOOGLE_APPLICATION_CREDENTIALS_RAW
environment variable with the content of the credentials file - All native ways of authentication provided by Google Cloud SDK
- Using
GOOGLE_APPLICATION_CREDENTIALS
environment variable - Reading credential file from default paths (see https://cloud.google.com/docs/authentication/application-default-credentials#personal)
- For all options see https://cloud.google.com/docs/authentication/provide-credentials-adc#how-to
- Using
GCS backend supports decompression of objects. The decision whether to decompress object or not is based on the comp-type
header in the object's metadata.
If the header is present and contains zstd
value, the object is decompressed on the fly. Otherwise the object is downloaded as is.
The only supported compression algorithm is currently zstd
.
Example for monix.eval.Task
:
import com.avast.clients.storage.gcs.GcsStorageBackend
import com.typesafe.config.Config
import monix.eval.Task
import monix.execution.Scheduler
import cats.effect.Blocker
implicit val scheduler: Scheduler = ???
val blocker: Blocker = ???
val config: Config = ???
GcsStorageBackend.fromConfig[Task](config, blocker).map{ resource =>
resource.use { client =>
client.get(sha256, destinationFile)
}
}