if(length > 0)
range = paste0(range, offset + length - 1)
-
+
fileURL = paste0(private$collection$api$getWebDavHostName(),
"c=", private$collection$uuid, "/", self$getRelativePath());
if(offset == 0 && length == 0)
{
headers <- list(Authorization = paste("OAuth2",
- private$collection$api$getToken()))
+ private$collection$api$getToken()))
}
else
{
- headers <- list(Authorization = paste("OAuth2", private$collection$api$getToken()),
+ headers <- list(Authorization = paste("OAuth2", private$collection$api$getToken()),
Range = range)
}
parsedServerResponse <- httr::content(serverResponse, contentType)
parsedServerResponse
},
-
+
+ connection = function(rw)
+ {
+ if (rw == "r") {
+ return(textConnection(self$read("text")))
+ } else if (rw == "w") {
+ private$buffer <- textConnection(NULL, "w")
+ return(private$buffer)
+ }
+ },
+
+ flush = function() {
+ v <- textConnectionValue(private$buffer)
+ close(private$buffer)
+ self$write(paste(v, collapse='\n'))
+ },
+
write = function(content, contentType = "text/html")
{
if(is.null(private$collection))
stop("ArvadosFile doesn't belong to any collection.")
- fileURL = paste0(private$collection$api$getWebDavHostName(),
+ fileURL = paste0(private$collection$api$getWebDavHostName(),
"c=", private$collection$uuid, "/", self$getRelativePath());
- headers <- list(Authorization = paste("OAuth2", private$collection$api$getToken()),
+ headers <- list(Authorization = paste("OAuth2", private$collection$api$getToken()),
"Content-Type" = contentType)
body <- content
parent = NULL,
collection = NULL,
http = NULL,
- httpParser = NULL
+ httpParser = NULL,
+ buffer = NULL
),
-
+
cloneable = FALSE
)
--------------------------------------------------------------------------------------------------------------------------------
-#Get file/folder content as character vector
+#Get list of files
-collection$getFileContent()
+collection$getFileListing()
--------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------
+#Read a table
+
+arvadosFile <- collection$get("myinput.txt")
+arvConnection <- arvadosFile$connection("r")
+mytable <- read.table(arvConnection)
+
+#Write a table
+
+arvadosFile <- collection$create("myoutput.txt")
+arvConnection <- arvadosFile$connection("w")
+write.table(mytable, arvConnection)
+arvadosFile$flush()
+
+--------------------------------------------------------------------------------------------------------------------------------
+
#Read whole file or just a portion of it.
fileContent <- arvadosFile$read()