Skip to content

Commit

Permalink
obiba/opal#3627 Unarchive file in place using opal.file_unzip()
Browse files Browse the repository at this point in the history
  • Loading branch information
ymarcon committed May 21, 2021
1 parent aa7fe8d commit 196ac48
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
10 changes: 6 additions & 4 deletions R/opal.file.R
Original file line number Diff line number Diff line change
Expand Up @@ -370,21 +370,23 @@ opal.file_read <- function(opal, source, destination) {
#' @param source Path to the file in the Opal file system (must exist and have the ".zip" file extension).
#' @param destination Path to the destination file or folder in the Opal file system.
#' @param key Key to decrypt archive.
#' @return The path of the extracted archive folder in the Opal file system.
#' @examples
#' \dontrun{
#' o <- opal.login('administrator','password', url='https://opal-demo.obiba.org')
#' # unzip
#' opal.file_unzip(o, "/tmp/TESTING.zip", "/home/administrator")
#' path <- opal.file_unzip(o, "/tmp/TESTING.zip", "/home/administrator")
#' opal.logout(o)
#' }
#' @export
opal.file_unzip <- function(opal, source, destination, key=NULL) {
query <- list(destination=destination)
query <- list(action = "unzip", destination = destination)

if (!is.null(key)) {
query["key"] <- key
}

location <- append("files", append("_unzip", strsplit(substring(source, 2), "/")[[1]]))
res <- opal.post(opal, location, query=query, acceptType='text/plain')
location <- append("files", strsplit(substring(source, 2), "/")[[1]])
res <- opal.post(opal, location, query=query, contentType = "application/json")
res$path
}
46 changes: 46 additions & 0 deletions man/opal.file_unzip.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 196ac48

Please sign in to comment.