retrieve: Retrieve file references from remote locations

Description Usage Arguments Methods Examples

Description

This method retrieve files referenced by its first argument to locations determined by its second argument. The return value is a FileReferences object summarizing the destination.

Usage

1
retrieve(from, to, ...)

Arguments

from

The source from which objects will be retrieved; typically (or exclusively, depending on method) ‘remote’ locations accessible via, e.g., http.

to

The destination to which files will be copied; typically on the local file system.

...

Additional arguments, passed to the function performing the download.

Methods

from = "FileReferences", to = "character"

from contains remote urls; files must be retrievable using getBinaryURL from the RCurl package. ... arguments are passed to getBinaryURL. to is a directory name to which files will be copied; the directory is created if it does not exist. File names will be unique.

from = "FileReferences", to = "FileReferences"

from is as in retrieve,FileReferences,character-method. to specifies destination urls; urls(to) must have the same number of elements as urls{from}, must not already exist on the local file system, and must not require creation of new directories. localNames and types of to are replaced by corresponding elements from from.

from = "FileReferences", to = "missing"

from is as in the retrieve,FileReferences,character-method. The destination is created using tempfile(), and forwarding this as the second argument to retrieve,FileReferences,character-method. The effect is to retrieve files to R's temporary directory; these files will be removed when the R session ends.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
try({ # fails when no internet available
    from <- FileReferences(c("http://bioconductor.org/biocLite.R",
                             "http://bioconductor.org/index.html"))
    ## to R's temporary directory
    to <- retrieve(from)
    urls(to)
    localNames(to)

    ## tell R where to copy files to
    toDir <- tempfile()
    dir.create(toDir, recursive=TRUE)
    toUrls <- file.path(toDir, localNames(from))
    retrieve(from, FileReferences(toUrls))
    list.files(toDir)
})

RWebServices documentation built on Oct. 5, 2016, 4:53 a.m.