| Title: | Interface to 'rclone' Cloud Storage Utility |
|---|---|
| Description: | Provides an R interface to 'rclone' <https://rclone.org>, a command-line program for managing files on cloud storage. 'rclone' supports over 40 cloud storage providers including 'S3'-compatible services ('Amazon S3', 'MinIO', 'Ceph'), 'Google Cloud Storage', 'Azure Blob Storage', and many others. This package downloads and manages the 'rclone' binary automatically and wraps its commands as R functions, returning results as data frames where appropriate. |
| Authors: | Carl Boettiger [aut, cre] (ORCID: <https://orcid.org/0000-0002-1642-628X>) |
| Maintainer: | Carl Boettiger <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.1 |
| Built: | 2026-05-26 08:45:45 UTC |
| Source: | https://github.com/boettiger-lab/rcloner |
Downloads and installs the rclone binary for the current platform. The binary is stored in a user-writable directory and does not require system-level installation.
install_rclone( force = FALSE, dest = getOption("rcloner.dir", tools::R_user_dir("rcloner", "data")) )install_rclone( force = FALSE, dest = getOption("rcloner.dir", tools::R_user_dir("rcloner", "data")) )
force |
Logical; if |
dest |
Directory in which to install rclone. Defaults to the value of
|
Invisibly, the path to the installed rclone binary.
## Not run: install_rclone() ## End(Not run)## Not run: install_rclone() ## End(Not run)
Low-level wrapper that runs any rclone command. Higher-level functions like
rclone_copy(), rclone_ls(), etc. call this internally.
rclone(args = character(), env = NULL, echo = FALSE, error_on_status = TRUE)rclone(args = character(), env = NULL, echo = FALSE, error_on_status = TRUE)
args |
Character vector of arguments passed to rclone (the command and its flags). Alternatively a single space-delimited string. |
env |
Named character vector of environment variables, or |
echo |
Logical; if |
error_on_status |
Logical; if |
A list with elements status, stdout, stderr, and timeout
(invisibly).
rclone("version") ## Not run: rclone(c("ls", "myremote:mybucket")) ## End(Not run)rclone("version") ## Not run: rclone(c("ls", "myremote:mybucket")) ## End(Not run)
Get quota information for a remote
rclone_about(path)rclone_about(path)
path |
Remote name or path (e.g. |
A list with quota details (free, used, total bytes).
## Not run: rclone_about("myremote:") ## End(Not run)## Not run: rclone_about("myremote:") ## End(Not run)
Returns TRUE if the rclone binary can be found and executed.
Useful as a condition for \examplesIf.
rclone_available()rclone_available()
Logical scalar.
rclone_available()rclone_available()
Reads the content of a remote file and returns it as a character string,
analogous to cat on the command line.
rclone_cat(path)rclone_cat(path)
path |
Remote path to the file. |
Character string with the file content.
tmp <- tempfile(fileext = ".txt") writeLines("hello rclone", tmp) txt <- rclone_cat(tmp) cat(txt) ## Not run: txt <- rclone_cat("myremote:bucket/readme.txt") cat(txt) ## End(Not run)tmp <- tempfile(fileext = ".txt") writeLines("hello rclone", tmp) txt <- rclone_cat(tmp) cat(txt) ## Not run: txt <- rclone_cat("myremote:bucket/readme.txt") cat(txt) ## End(Not run)
Compares the files in src and dest without transferring anything.
Differences are reported as messages.
rclone_check(src, dest, ...)rclone_check(src, dest, ...)
src |
Source path. |
dest |
Destination path. |
... |
Additional rclone flags. |
Invisibly, the rclone result list (check stderr for differences).
src <- tempfile() dir.create(src) dest <- tempfile() dir.create(dest) rclone_check(src, dest)src <- tempfile() dir.create(src) dest <- tempfile() dir.create(dest) rclone_check(src, dest)
Creates or updates a named remote in the rclone config file. This is the primary way to register cloud storage credentials with rclone.
rclone_config_create(name, type, ...)rclone_config_create(name, type, ...)
name |
Name for the remote (used as the prefix in paths, e.g.
|
type |
Remote type, e.g. |
... |
Named parameters passed to the remote configuration. For S3
remotes this typically includes |
Invisibly, the result of the rclone command.
## Not run: # AWS S3 rclone_config_create("aws", type = "s3", provider = "AWS", access_key_id = Sys.getenv("AWS_ACCESS_KEY_ID"), secret_access_key = Sys.getenv("AWS_SECRET_ACCESS_KEY"), region = "us-east-1" ) # MinIO / S3-compatible rclone_config_create("minio", type = "s3", provider = "Minio", access_key_id = Sys.getenv("MINIO_ACCESS_KEY"), secret_access_key = Sys.getenv("MINIO_SECRET_KEY"), endpoint = "https://minio.example.com" ) ## End(Not run)## Not run: # AWS S3 rclone_config_create("aws", type = "s3", provider = "AWS", access_key_id = Sys.getenv("AWS_ACCESS_KEY_ID"), secret_access_key = Sys.getenv("AWS_SECRET_ACCESS_KEY"), region = "us-east-1" ) # MinIO / S3-compatible rclone_config_create("minio", type = "s3", provider = "Minio", access_key_id = Sys.getenv("MINIO_ACCESS_KEY"), secret_access_key = Sys.getenv("MINIO_SECRET_KEY"), endpoint = "https://minio.example.com" ) ## End(Not run)
Delete an rclone remote
rclone_config_delete(name)rclone_config_delete(name)
name |
Remote name to delete. |
Invisibly, the result of the rclone command.
## Not run: rclone_config_delete("myremote") ## End(Not run)## Not run: rclone_config_delete("myremote") ## End(Not run)
Set individual parameters on an existing remote
rclone_config_set(name, ...)rclone_config_set(name, ...)
name |
Remote name. |
... |
Named parameters to set (key = value). |
Invisibly, the result of the rclone command.
## Not run: rclone_config_set("myremote", region = "us-west-2") ## End(Not run)## Not run: rclone_config_set("myremote", region = "us-west-2") ## End(Not run)
Show rclone configuration
rclone_config_show(name = NULL)rclone_config_show(name = NULL)
name |
Optional remote name. If omitted, shows all remotes. |
Character string with the configuration (invisibly). Also prints to the console.
rclone_config_show()rclone_config_show()
Copies files from src to dest, skipping files that are identical.
Does not delete files at the destination.
rclone_copy(src, dest, progress = FALSE, ...)rclone_copy(src, dest, progress = FALSE, ...)
src |
Source path (local or remote). |
dest |
Destination path (local or remote). |
progress |
Logical; show transfer progress. Default |
... |
Additional rclone flags as character strings. |
Invisibly, the rclone result list.
src <- tempfile() dir.create(src) writeLines("hello", file.path(src, "file.txt")) dest <- tempfile() rclone_copy(src, dest) list.files(dest) ## Not run: rclone_copy("myremote:bucket/file.csv", "/tmp/file.csv") ## End(Not run)src <- tempfile() dir.create(src) writeLines("hello", file.path(src, "file.txt")) dest <- tempfile() rclone_copy(src, dest) list.files(dest) ## Not run: rclone_copy("myremote:bucket/file.csv", "/tmp/file.csv") ## End(Not run)
Downloads a URL and uploads it to dest without storing it locally first.
rclone_copyurl(url, dest, ...)rclone_copyurl(url, dest, ...)
url |
URL to copy. |
dest |
Destination remote path. |
... |
Additional rclone flags. |
Invisibly, the rclone result list.
## Not run: rclone_copyurl("https://example.com/data.csv", "myremote:bucket/data.csv") ## End(Not run)## Not run: rclone_copyurl("https://example.com/data.csv", "myremote:bucket/data.csv") ## End(Not run)
Deletes the files (not directories) at the given path. To remove a directory
and all its contents use rclone_purge().
rclone_delete(path, ...)rclone_delete(path, ...)
path |
Remote path to delete. |
... |
Additional rclone flags. |
Invisibly, the rclone result list.
d <- tempfile() dir.create(d) writeLines("hi", file.path(d, "f.txt")) rclone_delete(d)d <- tempfile() dir.create(d) writeLines("hi", file.path(d, "f.txt")) rclone_delete(d)
Not all remotes support this operation.
rclone_link(path)rclone_link(path)
path |
Remote path to the file. |
Character string with the public URL.
## Not run: rclone_link("myremote:bucket/file.csv") ## End(Not run)## Not run: rclone_link("myremote:bucket/file.csv") ## End(Not run)
List configured remotes
rclone_listremotes()rclone_listremotes()
Character vector of remote names.
rclone_listremotes()rclone_listremotes()
Returns a data frame of objects at the given path, parsed from rclone's JSON
output. This is the primary listing function and maps to rclone lsjson.
rclone_ls(path, recursive = FALSE, dirs_only = FALSE, files_only = FALSE, ...)rclone_ls(path, recursive = FALSE, dirs_only = FALSE, files_only = FALSE, ...)
path |
Remote path in rclone syntax, e.g. |
recursive |
Logical; if |
dirs_only |
Logical; if |
files_only |
Logical; if |
... |
Additional flags passed to |
A data frame with columns Path, Name, Size, MimeType,
ModTime, IsDir, and optionally others returned by rclone.
rclone_ls(tempdir()) rclone_ls(tempdir(), recursive = TRUE) ## Not run: rclone_ls("myremote:mybucket") ## End(Not run)rclone_ls(tempdir()) rclone_ls(tempdir(), recursive = TRUE) ## Not run: rclone_ls("myremote:mybucket") ## End(Not run)
Convenience wrapper around rclone_ls() that returns only directories.
rclone_lsd(path, recursive = FALSE, ...)rclone_lsd(path, recursive = FALSE, ...)
path |
Remote path in rclone syntax, e.g. |
recursive |
Logical; if |
... |
Additional flags passed to |
A data frame (see rclone_ls()).
rclone_lsd(tempdir())rclone_lsd(tempdir())
Create a directory or bucket
rclone_mkdir(path)rclone_mkdir(path)
path |
Remote path to create. |
Invisibly, the rclone result list.
d <- tempfile() rclone_mkdir(d)d <- tempfile() rclone_mkdir(d)
Moves files from src to dest. Source files are deleted after a
successful transfer.
rclone_move(src, dest, progress = FALSE, ...)rclone_move(src, dest, progress = FALSE, ...)
src |
Source path (local or remote). |
dest |
Destination path (local or remote). |
progress |
Logical; show transfer progress. Default |
... |
Additional rclone flags as character strings. |
Invisibly, the rclone result list.
src <- tempfile() dir.create(src) writeLines("hello", file.path(src, "file.txt")) dest <- tempfile() rclone_move(src, dest)src <- tempfile() dir.create(src) writeLines("hello", file.path(src, "file.txt")) dest <- tempfile() rclone_move(src, dest)
Deletes all files and directories under path. Use with caution.
rclone_purge(path)rclone_purge(path)
path |
Remote path to purge. |
Invisibly, the rclone result list.
d <- tempfile() dir.create(d) writeLines("hi", file.path(d, "f.txt")) rclone_purge(d)d <- tempfile() dir.create(d) writeLines("hi", file.path(d, "f.txt")) rclone_purge(d)
Remove an empty directory
rclone_rmdir(path)rclone_rmdir(path)
path |
Remote path to the directory. |
Invisibly, the rclone result list.
d <- tempfile() dir.create(d) rclone_rmdir(d)d <- tempfile() dir.create(d) rclone_rmdir(d)
Get total size of a remote path
rclone_size(path)rclone_size(path)
path |
Remote path. |
A named list with count (number of objects) and bytes (total
size in bytes).
rclone_size(tempdir())rclone_size(tempdir())
Get metadata for a single object
rclone_stat(path)rclone_stat(path)
path |
Remote path to a single object. |
A one-row data frame with object metadata, or an error if not found.
f <- tempfile() writeLines("hello", f) rclone_stat(f)f <- tempfile() writeLines("hello", f) rclone_stat(f)
Makes dest identical to src, deleting files in dest that are not
in src. Use rclone_copy() if you do not want deletions.
rclone_sync(src, dest, progress = FALSE, ...)rclone_sync(src, dest, progress = FALSE, ...)
src |
Source path (local or remote). |
dest |
Destination path (local or remote). |
progress |
Logical; show transfer progress. Default |
... |
Additional rclone flags as character strings. |
Invisibly, the rclone result list.
src <- tempfile() dir.create(src) writeLines("hello", file.path(src, "file.txt")) dest <- tempfile() rclone_sync(src, dest) ## Not run: rclone_sync("myremote:bucket", "/local/backup") ## End(Not run)src <- tempfile() dir.create(src) writeLines("hello", file.path(src, "file.txt")) dest <- tempfile() rclone_sync(src, dest) ## Not run: rclone_sync("myremote:bucket", "/local/backup") ## End(Not run)
Show rclone version information
rclone_version()rclone_version()
Invisibly, a character string with the version output.
rclone_version()rclone_version()