This may be two separate issues under the hood, but I encountered both while trying to access a specific version of a figshare article.
This is the article in question. Its id is 7438598. In case it matters, I am one of the maintainers of this article, but the files/data are publicly accessible, and the code I'm writing is designed to be used by people who do not necessarily have edit/author access to the article.
The most recent version of this article is version 3.
Based on #58, I wrote the following code:
# Access the figshare repo ------------------------------------------------
repo <- rfigshare::fs_details("7438598", mine = FALSE, session = NULL)
# the mine = FALSE and session = NULL arguments are necessary to avoid authentication, as per issue #58.
# 7438598 is the code for the MFE figshare.
# Get list of file names
filenames <- lapply(repo[["files"]], function(x) x$name) %>% unlist()
# Get URL for database file download: I want to download the file called "MFEdb.db"
url <- repo[["files"]][[which(filenames == "MFEdb.db")]]$download_url
# Download the database file
download.file(url = url, # download just the database file into the home directory
destfile = "MFEdb.db", mode = "wb")
The above works very well; I can successfully download the most recent version of the target file.
The problem is that I would like to also access past versions. To do this, I tried to use the show_versions and/or version arguments in fs_details(), but neither of these arguments worked.
Problem 1: show_versions
If I replace the first line of the above code with this:
No encoding supplied: defaulting to UTF-8. # this is just a warning that I also get without show_versions = T; not worried about this.
Error in class(output) <- "fs_object" : # this is the problem.
attempt to set an attribute on NULL
I'm not sure what this error means, but the object repo is not created.
Problem 2: version
Instead of showing available versions, I tried to just specify an earlier version directly to fs_details().
This time, there was no error, but the resulting object looks really different than the output when the version argument is not specified. For example:
> names(repo) # note that "files" is missing!
[1] "url" "status_code" "headers" "all_headers" "cookies" "content" "date"
[8] "times" "request" "handle"
Most notably, repo$files is missing, so I'm not sure how to access specific files for download from previous versions.
Can anyone help with one or both of these issues? For problem 1, am I doing something wrong, or is this a bug? For problem 2, is this expected behavior, and if so, is there a way I can download a specific file from a previous version as I did for the most recent version?
This may be two separate issues under the hood, but I encountered both while trying to access a specific version of a figshare article.
This is the article in question. Its id is 7438598. In case it matters, I am one of the maintainers of this article, but the files/data are publicly accessible, and the code I'm writing is designed to be used by people who do not necessarily have edit/author access to the article.
The most recent version of this article is version 3.
Based on #58, I wrote the following code:
The above works very well; I can successfully download the most recent version of the target file.
The problem is that I would like to also access past versions. To do this, I tried to use the
show_versions
and/orversion
arguments infs_details()
, but neither of these arguments worked.Problem 1:
show_versions
If I replace the first line of the above code with this:
I get the following error:
I'm not sure what this error means, but the object
repo
is not created.Problem 2:
version
Instead of showing available versions, I tried to just specify an earlier version directly to
fs_details()
.This time, there was no error, but the resulting object looks really different than the output when the
version
argument is not specified. For example:Most notably, repo$files is missing, so I'm not sure how to access specific files for download from previous versions.
Can anyone help with one or both of these issues? For problem 1, am I doing something wrong, or is this a bug? For problem 2, is this expected behavior, and if so, is there a way I can download a specific file from a previous version as I did for the most recent version?
Thank you!