Skip to contents

Uploads a file to S3-compatible storage (e.g., MinIO) using credentials from the configuration file. The function supports custom S3 endpoints and handles authentication automatically.

Usage

upload_to_s3(
  file_path,
  s3_path = NULL,
  cfg = NULL,
  bucket = NULL,
  overwrite = FALSE
)

Arguments

file_path

character Local path to the file to upload.

s3_path

character Path in S3 bucket where the file should be stored (relative to bucket root). If NULL, uses the basename of file_path.

cfg

list Configuration object containing S3 settings. If NULL, will attempt to load from package configuration.

bucket

character S3 bucket name. If NULL, uses value from cfg.

overwrite

logical Whether to overwrite existing files. Default TRUE.

Value

Invisible TRUE if successful, FALSE otherwise.

Examples

if (FALSE) { # \dontrun{
# Upload a NetCDF file
upload_to_s3(
  file_path = "path/to/file.nc",
  s3_path = "Runs/v1.0/file.nc"
)

# Upload with custom configuration
cfg <- list(s3 = list(
  endpoint = "https://minio.example.com",
  access_key = "key",
  secret_key = "secret",
  bucket = "mybucket"
))
upload_to_s3("file.nc", "data/file.nc", cfg = cfg)
} # }