Skip to content

Commit

Permalink
fix #64
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Nov 24, 2021
1 parent 4950c40 commit 5ac13f7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

* [#62](https://github.com/eblondel/zen4R/issues/62) Fix new file upload API - wrong filename spliting
* [#63](https://github.com/eblondel/zen4R/issues/63) Fix new file upload API - case with filename with spaces
* [#64](https://github.com/eblondel/zen4R/issues/64) Fix new file upload API - actual file upload

## **_0.5-1_**

Expand Down
19 changes: 15 additions & 4 deletions R/ZenodoManager.R
Original file line number Diff line number Diff line change
Expand Up @@ -913,10 +913,21 @@ ZenodoManager <- R6Class("ZenodoManager",
method <- if(newapi) "PUT" else "POST"
if(newapi) self$INFO(sprintf("Using new file upload API with bucket: %s", record$links$bucket))
method_url <- if(newapi) sprintf("%s/%s", unlist(strsplit(record$links$bucket, "api/"))[2], URLencode(filename)) else sprintf("deposit/depositions/%s/files", recordId)
zenReq <- ZenodoRequest$new(private$url, method, method_url,
data = filename, file = upload_file(path),
token = self$getToken(),
logger = self$loggerType)
zenReq <- if(newapi){
ZenodoRequest$new(
private$url, method, method_url,
data = upload_file(path),
token = self$getToken(),
logger = self$loggerType
)
}else{
ZenodoRequest$new(
private$url, method, method_url,
data = filename, file = upload_file(path),
token = self$getToken(),
logger = self$loggerType
)
}
zenReq$execute()
out <- NULL
if(zenReq$getStatus() == 201){
Expand Down
2 changes: 1 addition & 1 deletion R/ZenodoRequest.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ ZenodoRequest <- R6Class("ZenodoRequest",
PUT = function(url, request, data){
req <- paste(url, request, sep="/")

data <- private$prepareData(data)
if(regexpr("api/files", req)<0) data <- private$prepareData(data)

#headers
headers <- c("Content-Type" = if(regexpr("api/files", req)>0) "application/octet-stream" else "application/json",
Expand Down

0 comments on commit 5ac13f7

Please sign in to comment.