WARNING: this function is deprecated. Redirection is no longer supported in the latest alabaster framework. Create a redirection to another path in the same staging directory. This is useful for creating short-hand aliases for resources that have inconveniently long paths.
createRedirection(dir, src, dest)
String containing the path to the staging directory.
String containing the source path relative to dir
.
String containing the destination path relative to dir
.
This may be any path that can also be used in acquireMetadata
.
A list of metadata that can be processed by writeMetadata
.
src
should not correspond to an existing file inside dir
.
This avoids ambiguity when attempting to load src
via acquireMetadata
.
Otherwise, it would be unclear as to whether the user wants the file at src
or the redirection target dest
.
src
may correspond to existing directories.
This is because directories cannot be used in acquireMetadata
, so no such ambiguity exists.
# Staging an example DataFrame:
library(S4Vectors)
df <- DataFrame(A=1:10, B=LETTERS[1:10])
tmp <- tempfile()
dir.create(tmp)
info <- stageObject(df, tmp, path="coldata")
writeMetadata(info, tmp)
#> $type
#> [1] "local"
#>
#> $path
#> [1] "coldata/simple.csv.gz"
#>
# Creating a redirection:
redirect <- createRedirection(tmp, "foobar", "coldata/simple.csv.gz")
writeMetadata(redirect, tmp)
#> $type
#> [1] "local"
#>
#> $path
#> [1] "foobar"
#>
# We can then use this redirect to pull out metadata:
info2 <- acquireMetadata(tmp, "foobar")
str(info2)
#> List of 6
#> $ $schema : chr "csv_data_frame/v1.json"
#> $ path : chr "coldata/simple.csv.gz"
#> $ is_child : logi FALSE
#> $ data_frame :List of 4
#> ..$ columns :List of 2
#> .. ..$ :List of 2
#> .. .. ..$ name: chr "A"
#> .. .. ..$ type: chr "integer"
#> .. ..$ :List of 2
#> .. .. ..$ name: chr "B"
#> .. .. ..$ type: chr "string"
#> ..$ row_names : logi FALSE
#> ..$ dimensions:List of 2
#> .. ..$ : int 10
#> .. ..$ : int 2
#> ..$ version : int 2
#> $ csv_data_frame:List of 1
#> ..$ compression: chr "gzip"
#> $ md5sum : chr "042b00e066dfa96577b5d6ac3c3ee700"