From a12fe11888dfa3ee863f73e05b9182ca104f863a Mon Sep 17 00:00:00 2001 From: eblondel Date: Wed, 18 Oct 2023 14:12:51 +0200 Subject: [PATCH] #135 getFile (metadata) --- R/ZenodoManager.R | 18 ++++++++++++++++++ man/ZenodoManager.Rd | 23 +++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/R/ZenodoManager.R b/R/ZenodoManager.R index ceac922..6216e7c 100644 --- a/R/ZenodoManager.R +++ b/R/ZenodoManager.R @@ -1007,6 +1007,24 @@ ZenodoManager <- R6Class("ZenodoManager", return(out) }, + #' @description Get a file record metadata. + #' @param recordId the ID of the record. + #' @param filename filename + #' @return the file metadata + getFile = function(recordId, filename){ + zenReq <- ZenodoRequest$new(private$url, "GET", sprintf("records/%s/draft/files/%s", recordId, filename), + token = self$getToken(), + logger = self$loggerType) + zenReq$execute() + out <- zenReq$getResponse() + if(zenReq$getStatus() == 200){ + self$INFO(sprintf("Successful fetched file metadata for record '%s' - filename '%s'", recordId, filename)) + }else{ + self$ERROR(sprintf("Error while fetching file(s) for record '%s': %s", recordId, out$message)) + } + return(out) + }, + #' @description Start a file upload. The method will create a key for the file to be uploaded #' This method is essentially for internal purpose, and is called directly in \code{uploadFile} #' for user convenience and for backward compatibility with the legacy Zenodo API. diff --git a/man/ZenodoManager.Rd b/man/ZenodoManager.Rd index 65cff1f..0fcfe73 100644 --- a/man/ZenodoManager.Rd +++ b/man/ZenodoManager.Rd @@ -122,6 +122,7 @@ Emmanuel Blondel \item \href{#method-ZenodoManager-discardChanges}{\code{ZenodoManager$discardChanges()}} \item \href{#method-ZenodoManager-publishRecord}{\code{ZenodoManager$publishRecord()}} \item \href{#method-ZenodoManager-getFiles}{\code{ZenodoManager$getFiles()}} +\item \href{#method-ZenodoManager-getFile}{\code{ZenodoManager$getFile()}} \item \href{#method-ZenodoManager-startFileUpload}{\code{ZenodoManager$startFileUpload()}} \item \href{#method-ZenodoManager-completeFileUpload}{\code{ZenodoManager$completeFileUpload()}} \item \href{#method-ZenodoManager-uploadFile}{\code{ZenodoManager$uploadFile()}} @@ -879,6 +880,28 @@ list of files } } \if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ZenodoManager-getFile}{}}} +\subsection{Method \code{getFile()}}{ +Get a file record metadata. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ZenodoManager$getFile(recordId, filename)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{recordId}}{the ID of the record.} + +\item{\code{filename}}{filename} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the file metadata +} +} +\if{html}{\out{
}} \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-ZenodoManager-startFileUpload}{}}} \subsection{Method \code{startFileUpload()}}{