Fetch a single file from the registry. This will call the REST API if the caller is not on the same filesystem as the registry.

fetchFile(
  path,
  registry,
  url,
  cache = NULL,
  forceRemote = FALSE,
  overwrite = FALSE
)

Arguments

path

String containing the relative path to a file within the registry. This usually takes the form of PROJECT/ASSET/VERSION/*, where path components should be separated by /.

registry

String containing a path to the registry.

url

String containing the URL to the Gobbler REST API. Only used for remote access.

cache

String containing a path to a cache directory. If NULL, an appropriate location is automatically chosen. Only used for remote access.

forceRemote

Logical scalar indicating whether to force remote access. This will download path via the REST API and cache it locally, even if path is on the same filesystem as the caller.

overwrite

Logical scalar indicating whether to overwrite the existing cache. Only used for remote access.

Value

String containing the path to the file on the caller's filesystem.

Author

Aaron Lun

Examples

info <- startGobbler()
removeProject("test", info$staging, url=info$url) # start with a clean slate.
createProject("test", info$staging, url=info$url)

# Mocking up an upload. 
src <- allocateUploadDirectory(info$staging)
write(file=file.path(src, "foo"), "BAR")
dir.create(file.path(src, "whee"))
write(file=file.path(src, "whee", "blah"), "stuff")
uploadDirectory("test", "simple", "v1", src, staging=info$staging, url=info$url)

fetchFile("test/simple/v1/foo", registry=info$registry, url=info$url)
#> [1] "/tmp/Rtmpk5zsYr/file21928641d8f/test/simple/v1/foo"
fetchFile("test/simple/v1/whee/blah", registry=info$registry, url=info$url, forceRemote=TRUE)
#> [1] "/github/home/.local/share/R/gobbler/http%3A%2F%2F0.0.0.0%3A5114/REGISTRY/test/simple/v1/whee/blah"