Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I get a listing of a shared link? #218

Open
jfunction opened this issue Aug 10, 2021 · 4 comments
Open

Can I get a listing of a shared link? #218

jfunction opened this issue Aug 10, 2021 · 4 comments

Comments

@jfunction
Copy link

I want to build something that looks at new content on a /s/ style link.

For example, I can navigate to https://app.box.com/s/abcdefghijklmnop/folder/1234567890 but when I tried boxr::ls('1234567890') I was told that "the folder specified does not exist in your account" which is true, but it is publicly accessible so I hoped there would be a way to access it through the API.

I think I want something like this https://developer.box.com/reference/get-shared-items--folders/ and the same with files, so I can figure out what is new based on the local content.

Any help would be appreciated. Thanks for this library.

@jfunction
Copy link
Author

For now I managed to make a plan with something like this:

library(tidyverse)
library(tidyjson)
library(httr)
library(boxr)
library(glue)
result <- GET(glue("https://api.box.com/2.0/folders/1234567890/items"),
              add_headers(boxapi='shared_link=https://foo.app.box.com/s/abcdefghijklmnop',
                          Authorization=glue('Bearer {getOption("boxr.token")$credentials$access_token}')))
# Then process files/folders in the response as a tibble by doing:
tbChildren <- content(result, as='text', encoding='UTF-8') %>%
    enter_object(entries) %>%
    gather_array() %>%
    spread_all()

Then I just called this recursively to enumerate all files and compared sha1 against disk to see what got messed up. We don't get a timestamp for comparison so probably couldn't do proper sync with this method but that's not my use case in this instance so I didn't chase that down any more.

I also noticed I didn't have permission to download the shared content via the API /files/1234567890/content endpoint, but I can download them via the web app by browsing to https://app.box.com/s/abcdefghijklmnop/file/1234567890, which seems like an oversight. I managed to download these resources using GET again by mimicking the browser method, though this might be against TOU... I didn't check...

Anyway, just wanted to report back. Maybe this information can improve the library by, for example, including the ability to add_headers(boxapi='shared_link=https://foo.app.box.com/s/abcdefghijklmnop') through the box_ls() method.

@nathancday
Copy link
Member

Thanks for the report back. Glad you found a way to work it.

Just so I'm on the same page as you are, your use case needed to expose the Find folder for shared link API? Either with a new boxr function or new argument to box_ls()?

@jfunction
Copy link
Author

Sorry for delay, but yes that sums it up. I also needed the Find file for shared link API.

@nathancday
Copy link
Member

That sounds like a possible new feature for boxr. Re-opening for visibility and interest to others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants