mantaPut: Uploads file(s) (vectorized), or raw R buffer data to Manta...

Description Usage Arguments Details Value See Also Examples

View source: R/mantaPut.R

Description

Transfers file, buffer to Manta Storage Object specified in mantapath. To save a file, specify the filename. It will go into the current working Manta directory with the same name unless absolute Manta path or relative object name is specified with the mantapath argument. To see the current directory on Manta use mantaGetwd, and mantaSetwd to change it.

Usage

1
2
mantaPut(filename, mantapath, buffer, md5 = FALSE, headers, info = TRUE,
  verbose = FALSE)

Arguments

mantapath

character, optional. Path to where uploaded data will go on Manta or Manta Object file name in current working Manta directory. If mantapath ends in "/" it is assumed to be specifying a Manta subdirectory and the filename portion is appended to it. Memory data uploads using buffer parameter require mantapath to have a destination file name at the end of the path with an extension for proper guessing of Content-Type header information.

filename

vector of character, optional. Path to local file to upload. If only a filename is given, assumes file is in path specified by getwd. Vectorized.

buffer

optional. Raw buffer of data to put. If filename is specified, buffer is ignored and filename contents are uploaded. Not vectorized.

md5

logical optional. Test md5 hash of file/raw buffer with OpenSSL before/after upload. TRUE by default, setting FALSE will speed up transfers a bit.

headers

optional. Headers including R structured metadata (up to 4k in user metadata) as array of named character E.g.
headers = c('content-type' = "image/jpg", 'x-durability-level' = 4) Manta user metadata is prefixed with "m-", E.g.
headers = c('content-type' = "x-chemical/x-pdb", 'm-molecule-class' = "protein")

info

logical required. FALSE silences output messages while downloading.

verbose

logical, optional. Passed to RCurl GetURL, Set to TRUE to see background REST communication on stderr Note this is not visible on Windows.

Details

To save a raw R buffer, pass the string with its name e.g. buffer = "myRawBuffer"

One limitation of the mantaRSDK is that it is not designed to handle large (multi-Gigabyte or larger) objects. Uploads - mantaPut - work from files, but Downloads - mantaGet - fill the R memory space to their completion before being written to a file. To download files larger than your R memory, use the Manta Node.js command line tool mget. The Node.js based Manta command line tools employ streams, so object size is not a limitation.

The Content-Type information metatdata for the file is obtained using the RCurl library function guessMIMEtype on the filename extension provided, e.g. .jpg or it can be set by passing a header parameter, which is an RCurl style HTTP header - a list of named character values like this:
header = c('content-type' = "image/jpg"). The default Content-Type header is "application/octet-stream". The number of copies (durability level) saved is by default 2. This can be changed by using headers like this:
headers = c('x-durability-level' = 4) for one-time use.
For larger operations use mantaSetLimits to change the default durability level for the current mantaRSDK session. The number of copies stored can range from 2 to 6. This function does not support streaming uploads, for that use the Node.js Manta command line interface (CLI). Other Manta operations involving HTTP conditional request semantics and CORS headers are not implemented in this R library, but can be used with the Node.js CLI which can be called from R with the system2 command shell. mantaPut is a wrapper for mantaXfer, which implements the actual RCURL data upload.

Value

TRUE or FALSE depending on success of upload.

See Also

mantaGet

Other mantaPut: mantaDump; mantaSave.image; mantaSave.ws

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
## Not run: 
## Save a static hello world HTML page
htmlpage <- paste("<!DOCTYPE html>\n<html>\n<body>\n\n",
                  "<h1>Hello from Joyent Manta.</h1>\n\n",
                  "<p>Hello world! from ",
                  mantaWhoami(),
                  ".</p>\n\n",
                  "</body>\n</html>", sep="")
file <- file("test_index.html", "wb")
write(htmlpage,file)
close(file)
rm(file)
rm(htmlpage)

## Upload the HTML file to Manta in your public area
mantaSetwd.public()
mantaPut("test_index.html")
mantaExists("test_index.html")
mantaCat("test_index.html")

ls()
buffer <- mantaGet("test_index.html", buffer = TRUE)
cat(rawToChar(buffer))

## Upload the raw buffer
mantaPut(mantapath = "~~/public/buffer_index.html", buffer = buffer)
mantaLs.l(grepfor = "[.]html")
mantaCat("buffer_index.html")

## Check file metadata to see Content-type
mantaGet("test_index.html", metadata = TRUE)
mantaGet("buffer_index.html", metadata = TRUE)

## copy and paste URL into browser.
mantaLs.url("~~/public", grepfor = "[.]html")

## Cleanup this demo
#mantaRm("~~/public/test_index.html")
#mantaRm("~~/public/buffer_index.html")
#file.remove("test_index.html")
#rm(buffer)

## End(Not run)

joyent/mantaRSDK documentation built on May 19, 2019, 10:43 p.m.