Skip to content

Commit

Permalink
fix #15
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Nov 29, 2022
1 parent fd1b2c6 commit 82e7bf2
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 14 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: d4storagehub4R
Version: 0.4-1
Date: 2022-08-19
Version: 0.4-2
Date: 2022-11-29
Title: Interface to 'D4Science' 'StorageHub' API
Authors@R: c(
person("Emmanuel", "Blondel", role = c("aut", "cre"), email = "emmanuel.blondel1@gmail.com", comment = c(ORCID = "0000-0002-5870-5762")))
Expand Down
8 changes: 7 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
## [d4storagehub4R 0.4-2](https://cran.r-project.org/package=d4storagehub4R) | [![CRAN_Status_Badge](https://img.shields.io/badge/CRAN-published-blue.svg)](https://cran.r-project.org/package=d4storagehub4R)

**New features**

* [#15](https://github.com/eblondel/d4storagehub4R/issues/15) Support `getPublicFileLinkByID` method

## [d4storagehub4R 0.4-1](https://cran.r-project.org/package=d4storagehub4R) | [![CRAN_Status_Badge](https://img.shields.io/badge/CRAN-published-blue.svg)](https://cran.r-project.org/package=d4storagehub4R)

**Enhancements**

* [#14](https://github.com/eblondel/d4storagehub4R/issues/14) Upgrade roxygen2 7.2.1 to fix html issues

## [d4storagehub4R 0.4](https://cran.r-project.org/package=d4storagehub4R) | [![CRAN_Status_Badge](https://img.shields.io/badge/CRAN-published-blue.svg)](https://cran.r-project.org/package=d4storagehub4R)
## [d4storagehub4R 0.4](https://cran.r-project.org/src/contrib/Archive/d4storagehub4R/d4storagehub4R_0.4.tar.gz) | [![CRAN_Status_Badge](https://img.shields.io/badge/CRAN-published-blue.svg)](https://cran.r-project.org/src/contrib/Archive/d4storagehub4R/d4storagehub4R_0.4.tar.gz)

**Enhancements**

Expand Down
31 changes: 20 additions & 11 deletions R/StoragehubManager.R
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,25 @@ StoragehubManager <- R6Class("StoragehubManager",
self$downloadItem(item = item, wd = wd)
},

#'@description Get public file link by ID
#'@param pathID file item ID
#'@return the public file URL
getPublicFileLinkByID = function(pathID){
link <- NULL
link_url <- sprintf("%s/items/%s/publiclink?exclude=hl:accounting", private$url_storagehub, pathID)
pl_req <- switch(private$token_type,
"gcube" = {
link_url <-paste0(link_url, "&gcube-token=", self$getToken())
httr::GET(link_url)
},
"jwt" = {
httr::GET(link_url, httr::add_headers("Authorization" = paste("Bearer", self$getToken())))
}
)
if(!is.null(pl_req)) link <- httr::content(pl_req)
return(link)
},

#'@description Get public file link
#'@param path file path
#'@return the public file URL
Expand All @@ -733,17 +752,7 @@ StoragehubManager <- R6Class("StoragehubManager",
self$ERROR(errMsg)
stop(errMsg)
}
link_url <- sprintf("%s/items/%s/publiclink?exclude=hl:accounting", private$url_storagehub, pathID)
pl_req <- switch(private$token_type,
"gcube" = {
link_url <-paste0(link_url, "&gcube-token=", self$getToken())
httr::GET(link_url)
},
"jwt" = {
httr::GET(link_url, httr::add_headers("Authorization" = paste("Bearer", self$getToken())))
}
)
if(!is.null(pl_req)) link <- httr::content(pl_req)
link <- self$getPublicFileLinkByID(pathID = pathID)
return(link)
}

Expand Down
21 changes: 21 additions & 0 deletions man/StoragehubManager.Rd

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

0 comments on commit 82e7bf2

Please sign in to comment.