Skip to contents

Generic implementing of how to download files from a connector:

Usage

download_cnt(connector_object, name, file = basename(name), ...)

# S3 method for class 'ConnectorFS'
download_cnt(connector_object, name, file = basename(name), ...)

Arguments

connector_object

Connector The connector object to use.

name

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

file

character Path to the file to download to or upload from

...

Additional arguments passed to the method for the individual connector.

Value

invisible connector_object.

Examples

# Download file from a file storage

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

cnt |>
  write_cnt("this is an example", "example.txt")
#> Error: Cannot open file for writing:
#> * '/tmp/RtmppxiTmW/file1fc04935b433/example.txt'

list.files(pattern = "example.txt")
#> character(0)

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

list.files(pattern = "example.txt")
#> character(0)
readLines("example.txt")
#> Warning: cannot open file 'example.txt': No such file or directory
#> Error in file(con, "r"): cannot open the connection

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