Trouble creating a new file from R using box_dir_create in boxr
AnsweredHi all,
I've been having difficulty getting boxr to successfully create a file within my box directory. My code reads:
```
library(boxr)
box_auth()
my_file_dir <- box_setwd("7***phone number removed for privacy***")
box_dir_create(dir_name="TEST", parent_dir_id = my_file_dir)
```
after running which, I get the following output:
```
box.com remote folder reference
name :
dir id :
size :
modified at :
created at :
uploaded by :
owned by :
shared link : None
parent folder name :
parent folder id :
```
Checking my box directory, I find no folders have been created.
I've tried using additional arguments within box_dir_create, but according to the documentation only dir_name and parent_dir_name are accepted.
Any help is much appreciated. I understand this is a somewhat obscure R package, so I've included links to the documentation below:
https://cran.r-project.org/web/packages/boxr/boxr.pdf
https://github.com/r-box/boxr
-
Hi all,I got an answer via the package's developer, and I figured I'd pay it forward for any fellow travelers in the future.
It turns out that box_setwd() sets a default directory but returns nothing. Using
box_dir_create(dir_name="TEST", parent_dir_id = "###########")
creates the folder successfully. It will not do so if a folder of the same name is already created.
After more digging, I was also told that box_dir_create() is quietly passing back a lot of useful information, including the newly created directory's ID. To access it you can save the function results as a variable, like so:
b <- box_dir_create("test_dir") names(b) # lots of info b$id # what you want box_ul(b$id, "image_file.jpg") # is this file by file? box_push(b$id, "image_directory/") # or a directory wide operation?
Thanks for your help, and I hope this helps someone else down the road. Cheers!
Please sign in to leave a comment.
Comments
2 comments