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

Get file path from file ID #157

Open
ashirwad opened this issue Jun 10, 2020 · 9 comments
Open

Get file path from file ID #157

ashirwad opened this issue Jun 10, 2020 · 9 comments

Comments

@ashirwad
Copy link
Contributor

Is it possible to get file path using the file ID?

@nathancday
Copy link
Member

nathancday commented Jun 10, 2020

Not today in terms of boxr, in terms of the Box API I don't know. I'm sure that info exists somewhere in the data structure, but not sure if the API makes it accessible. The Box API ref is my go-to, but I didn't see anything on a quick top level scan. If you find something do this in the API or another language, please share it here.

@ashirwad
Copy link
Contributor Author

@ashirwad
Copy link
Contributor Author

Also, I tried to use the API using the "Try this API" menu and got the following results:

image

By entering the file ID and running the API I was able to see the file path.

@nathancday
Copy link
Member

Cool. What is your use case?

@ashirwad
Copy link
Contributor Author

Here are my thoughts on how I might use the function that prints the file path when provided with the file ID:

  • In the code chunk of an Rmd file where I want to read a file into R using box_read(file_id) I also want to print the file path so that I know where the file is located. This way if later I want to use that file to develop some interactive visualizations using some BI tool such as Tableau , I can quickly locate it.

  • Also, one major advantage of using file_id is that the file_id remains the same even if the file is renamed or is reorganized into a different folder. The ability to print the file path will keep me aware of the change that's happening upstream (if I pair it with workflowr).

Do these points sound convincing to you?

@nathancday
Copy link
Member

I think for quickly locating files using IDs directly is best even via URLs. You also point out that the file path would be brittle while the ID is durable.

I can see combining this with your current version request in a box_file_info() function. Let me think about it some more.

@ashirwad
Copy link
Contributor Author

Oh, yes, you are right! Typically, my project advisor tells me that the file lives here::here("Data", "Raw", "File"). I then locate the file on Box Drive , right click on the file and use the option View on Box.com to obtain the file_id for use within *.Rmd using boxr. But just like you said, I can certainly reverse the process! Nevertheless, having the ability to print these information using box_file_info() would be helpful.

@nathancday
Copy link
Member

About the current version request, I made box_current_version() yesterday. It's over on this branch for now #159, if you want to check it out. Since the version and file-info APIs are different, combining them doesn't makes sense to me anymore.

Thinking about your use case of navigating to a file later for Tableau, would it be better to include a function that opens a browser tab directly to the file (based on ID). I don't like using paths that we know can break.

@ashirwad
Copy link
Contributor Author

Thanks, Nate! I will check it out. Also, I like your idea of using a function to open the Box file on click.

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

No branches or pull requests

2 participants