This service can be used to:
root: Set the work directory for backendbucket: Set the container name for backendendpoint: Customizable endpoint settingcredential: Service Account or External Account JSON, in base64credential_path: local path to Service Account or External Account JSON fileservice_account: name of Service Accountpredefined_acl: Predefined ACL for GCSdefault_storage_class: Default storage class for GCSRefer to public API docs for more information. For authentication related options, read on.
OpenDAL supports the following authentication options:
credentialcredential_pathGcsBackend will attempt to load Service Account key from ADC well-known places.service_account. Otherwise, nothing need to be set.GcsBuilder.credential_provider_chain()Notes:
use opendal_core::Operator; use opendal_core::Result; use opendal_service_gcs::Gcs; #[tokio::main] async fn main() -> Result<()> { // create backend builder let mut builder = Gcs::default() // set the storage bucket for OpenDAL .bucket("test") // set the working directory root for GCS // all operations will happen within it .root("/path/to/dir") // set the credentials with service account .credential("service account JSON in base64") // set the predefined ACL for GCS .predefined_acl("publicRead") // set the default storage class for GCS .default_storage_class("STANDARD"); let op: Operator = Operator::new(builder)?.finish(); Ok(()) }