The ConnectorFS class is a file storage connector for accessing and manipulating files any file storage solution. The default implementation includes methods for files stored on local or network drives.
We recommend using the wrapper function connector_fs()
to simplify the process of
creating an object of ConnectorFS class. It provides a more intuitive and user-friendly
approach to initialize the ConnectorFS class and its associated functionalities.
connector::Connector
-> ConnectorFS
path
character Path to the file storage
new()
Initializes the connector for file storage.
ConnectorFS$new(path, extra_class = NULL)
download_cnt()
Download content from the file storage. See also download_cnt.
ConnectorFS$download_cnt(name, file = basename(name), ...)
invisible connector_object.
upload_cnt()
Upload a file to the file storage. See also upload_cnt.
ConnectorFS$upload_cnt(file, name = basename(file), ...)
invisible self.
create_directory_cnt()
Create a directory in the file storage. See also create_directory_cnt.
name
character The name of the directory to create
...
Additional arguments passed to the method for the individual connector.
remove_directory_cnt()
Remove a directory from the file storage. See also remove_directory_cnt.
name
character The name of the directory to remove
...
Additional arguments passed to the method for the individual connector.
invisible self.
upload_directory_cnt()
Upload a directory to the file storage. See also upload_directory_cnt.
ConnectorFS$upload_directory_cnt(dir, name = basename(dir), ...)
invisible self.
download_directory_cnt()
Download a directory from the file storage. See also download_directory_cnt.
invisible connector_object.
tbl_cnt()
Use dplyr verbs to interact with the tibble. See also tbl_cnt.
name
character Name of the content to read, write, or remove. Typically the table name.
...
Additional arguments passed to the method for the individual connector.
# Create file storage connector
folder <- withr::local_tempdir()
cnt <- ConnectorFS$new(folder)
cnt
#> <ConnectorFS>
#> Inherits from: <Connector>
#> Registered methods:
#> • `create_directory_cnt.ConnectorFS()`
#> • `download_cnt.ConnectorFS()`
#> • `download_directory_cnt.ConnectorFS()`
#> • `list_content_cnt.ConnectorFS()`
#> • `log_read_connector.ConnectorFS()`
#> • `log_remove_connector.ConnectorFS()`
#> • `log_write_connector.ConnectorFS()`
#> • `read_cnt.ConnectorFS()`
#> • `remove_cnt.ConnectorFS()`
#> • `remove_directory_cnt.ConnectorFS()`
#> • `tbl_cnt.ConnectorFS()`
#> • `upload_cnt.ConnectorFS()`
#> • `upload_directory_cnt.ConnectorFS()`
#> • `write_cnt.ConnectorFS()`
#> Specifications:
#> • path: /tmp/RtmpWV8S1R/fileb9b42426461a
# You can do the same thing using wrapper function connector_fs()
cnt <- connector_fs(folder)
cnt
#> <ConnectorFS>
#> Inherits from: <Connector>
#> Registered methods:
#> • `create_directory_cnt.ConnectorFS()`
#> • `download_cnt.ConnectorFS()`
#> • `download_directory_cnt.ConnectorFS()`
#> • `list_content_cnt.ConnectorFS()`
#> • `log_read_connector.ConnectorFS()`
#> • `log_remove_connector.ConnectorFS()`
#> • `log_write_connector.ConnectorFS()`
#> • `read_cnt.ConnectorFS()`
#> • `remove_cnt.ConnectorFS()`
#> • `remove_directory_cnt.ConnectorFS()`
#> • `tbl_cnt.ConnectorFS()`
#> • `upload_cnt.ConnectorFS()`
#> • `upload_directory_cnt.ConnectorFS()`
#> • `write_cnt.ConnectorFS()`
#> Specifications:
#> • path: /tmp/RtmpWV8S1R/fileb9b42426461a
# List content
cnt$list_content_cnt()
#> character(0)
# Write to the connector
cnt$write_cnt(iris, "iris.rds")
#> Warning: cannot open file '/tmp/RtmpWV8S1R/fileb9b42426461a/iris.rds': No such file or directory
#> Error in saveRDS(x, con, version = version, refhook = refhook, ascii = text): cannot open the connection
# Check it is there
cnt$list_content_cnt()
#> character(0)
# Read the result back
cnt$read_cnt("iris.rds") |>
head()
#> Error in find_file(name, root = connector_object$path): No file found or multiple files found with the same name