osfr icon indicating copy to clipboard operation
osfr copied to clipboard

`osf_download` returns corrupted files

Open SHogenboom opened this issue 1 year ago • 1 comments

I was trying to understand the osfr package and tried to apply the following example from the [osfr documentation](

https://docs.ropensci.org/osfr/articles/getting_started.html#a-few-details-about-files-on-osf):

osf_retrieve_file("vbdah") %>%
  osf_download(excel_file)

This code does not work because the variable excel_file is not specified. Therefore I tried the code:

osf_retrieve_file("vbdah") %>%
  osf_download()

This appears to download the file (Calculating_Effect_Sizes.xlsx) while throwing the error:

Error in `.wb_download()`:
! The requested file (vbdah) could not be found in node `ixgcd`

When trying to access the file it turns out that it is in fact corrupted. I've had the same issue when trying to download zip files from url and identifier. Really not sure if I'm misunderstanding the documentation or that downloading directly from GUID no longer works.

SHogenboom avatar Aug 08 '22 17:08 SHogenboom

For my personal usecase the issue appeared to be in the type of id required by the osf_download() function.

The documentation specifies that the id as visible in the URL should suffice. Which is not the case, even for the example provided in the documentation. When manually moving through all the folders like so:

  project <-
    osfr::osf_retrieve_node(id = "ixgcd") |>
    osfr::osf_ls_files(
      n_max = Inf
    )

Ultimately, the id associated with the individual files is different from the id available via the URL:

id_url <- "vbdah"
id_project_file <- "5574619f8c5e4a1a5a7a03b4"

I presume this is the difference between the Waterbutler and the OSF id which was mentioned somewhere. When using this longer id the osf_download() function works again as expected.

SHogenboom avatar Aug 11 '22 10:08 SHogenboom