Skip to content

Commit

Permalink
uploading isatab directly from dir now possible
Browse files Browse the repository at this point in the history
  • Loading branch information
january3 committed Jan 29, 2025
1 parent 029cb51 commit 4dc1686
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
21 changes: 18 additions & 3 deletions R/baseapi.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,30 @@ sodar_investigation_retrieve <- function(project_uuid,
#' @importFrom httr upload_file
#' @return A list with the details of the import outcome.
#' @export
sodar_sheet_import <- function(project_uuid, file, config = NULL, verbose = getOption("verbose", default = FALSE), return_raw = FALSE) {
sodar_sheet_import <- function(project_uuid, zip = NULL, dir = NULL, config = NULL, verbose = getOption("verbose", default = FALSE), return_raw = FALSE) {

url <- paste0("/samplesheets/api/import/", project_uuid)
file_up <- upload_file(file)
body <- list(file = file_up)

if(is.null(zip) && is.null(dir)) {
stop("Either zip or dir must be provided.")
}

if(!is.null(zip)) {
file_up <- upload_file(file)
body <- list(file = file_up)
} else if(!is.null(dir)) {
files <- list.files(dir, include.dirs = FALSE, recursive = FALSE, full.names = TRUE)
names(files) <- basename(files)
body <- map(files, upload_file)
}

response <- .request_post(url, config, body = body, encode = "multipart", verbose = verbose)
return(.request_process(response, return_raw = return_raw))
}




#' Export an ISAtab sample sheet from a project
#'
#' This function exports an ISAtab sample sheet from a project.
Expand Down
2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pkgdown: 2.1.0
pkgdown_sha: ~
articles:
sodar_api: sodar_api.html
last_built: 2025-01-29T13:09Z
last_built: 2025-01-29T14:48Z
urls:
reference: https://bihealth.github.io/LimsaR/reference
article: https://bihealth.github.io/LimsaR/articles
11 changes: 6 additions & 5 deletions docs/reference/sodar_sheet_import.html

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

2 changes: 1 addition & 1 deletion docs/search.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions man/sodar_sheet_import.Rd

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

0 comments on commit 4dc1686

Please sign in to comment.