Skip to contents

Generic implementing of how to upload files to a connector:

Usage

upload_cnt(
  connector_object,
  file,
  name = basename(file),
  overwrite = zephyr::get_option("overwrite", "connector"),
  ...
)

# S3 method for class 'ConnectorFS'
upload_cnt(
  connector_object,
  file,
  name = basename(file),
  overwrite = zephyr::get_option("overwrite", "connector"),
  ...
)

Arguments

connector_object

Connector The connector object to use.

file

character Path to the file to download to or upload from

name

character Name of the content to read, write, or remove. Typically the table name.

overwrite

Overwrite existing content if it exists in the connector?. Default: FALSE.

...

Additional arguments passed to the method for the individual connector.

Value

invisible connector_object.

Examples

# Upload file to a file storage

writeLines("this is an example", "example.txt")

folder <- withr::local_tempdir()
cnt <- connector_fs(folder)

cnt |>
  list_content_cnt(pattern = "example.txt")
#> character(0)

cnt |>
  upload_cnt("example.txt")
#> Error: [ENOENT] Failed to copy 'example.txt' to '/tmp/RtmppxiTmW/file1fc058fa4140/example.txt': no such file or directory

cnt |>
  list_content_cnt(pattern = "example.txt")
#> character(0)

cnt |>
  remove_cnt("example.txt")
#> Error: [ENOENT] Failed to remove '/tmp/RtmppxiTmW/file1fc058fa4140/example.txt': no such file or directory

file.remove("example.txt")
#> [1] TRUE