osfr icon indicating copy to clipboard operation
osfr copied to clipboard

Feature request: download specific file versions

Open eshom opened this issue 3 years ago • 4 comments

It would be very useful to add an argument to either osf_retrieve_file() or osf_download() to choose a specific file version to download. Currently I had to resort to manually downloading specific versions using utils::download.file(). Hope to see something like this in the future!

eshom avatar Dec 31 '20 14:12 eshom

Hi @eshom. I agree file version support would be a useful addition to osfr. It's definitely on the roadmap.

aaronwolen avatar Feb 05 '21 21:02 aaronwolen

@eshom , would you mind sharing your code with the manual solution? I'm trying to figure out a way to do this programmatically, but can't see how.

egouldo avatar Aug 26 '21 04:08 egouldo

@egouldo Sure! Here's a reproducible example:

tmp <- tempfile()
base_url <- "https://osf.io/"
download_version_endpoint <- "/download?version="
quality_metrics <- "qpfw5"
version <- 1
download_url <- paste0(base_url, quality_metrics, download_version_endpoint, version)

cat("Downloading:\n")
download.file(download_url, tmp)

cat("Deleting", paste0("'", tmp, "'"), "\n")
file.remove(tmp)

eshom avatar Aug 26 '21 08:08 eshom

Awesome, thanks so much @eshom !

egouldo avatar Aug 26 '21 11:08 egouldo