Generic implementing of how to download files from a connector:
ConnectorFS: Uses
fs::file_copy()
to copy a file from the file storage to the desiredfile
.
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