box / box/boxcli

Allow for the creation of folder structures with the folders:create command

Open
#267 0 comments 1 reaction 2 assignees Claimed by @sujaygarlanka View on GitHub
enhancement
Dominant language
JavaScript
Stars
284
Forks
67
Avg merge
6h 45m
Merged PRs (30d)
4

Description

### Is your feature request related to a problem? Please describe.
Currently the folders:create endpoint can only create one folder per call which means creating deeper structures is complicated.

### Describe the solution you'd like
With some additional logic the command for creating folders could check for '/' in the requested folder name and create the whole given path if a path is given rather than a folder

### Describe alternatives you've considered
Alternatively this could be a separate command. eg. folders:createpath

### Additional context
I did a proof of concept with the code below added to the folders:create command
```
if(params.body.name.includes('/')) {
let pathParts = params.body.name.split('\/');
let createdFolder;
for (let i = 0; i < pathParts.length; i++) {
params.body.name=pathParts[i];
try {
createdFolder = await this.client.folders.create(params.body.parent.id,params.body.name);
params.body.parent.id=createdFolder.id
}
catch(error) {
if(error.statusCode==409) {
//console.log(error.response.body.context_info.conflicts[0].id);
params.body.parent.id=error.response.body.context_info.conflicts[0].id;
createdFolder=error.response.body.context_info.conflicts[0];
}
}
};
```
Example command output
![image (1)](https://user-images.githubusercontent.com/38443139/143059618-424e024d-a2da-4cd6-a741-ce7efb7aa7f6.png)
![image](https://user-images.githubusercontent.com/38443139/143059626-4069b83c-d076-4ce8-9280-88a33708cb53.png)

IT would also work with files CSV like this

![image (2)](https://user-images.githubusercontent.com/38443139/143059724-669ffd83-763f-493c-9281-9bdb2542af47.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.