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

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

Open
pchristensenB opened this issue Nov 23, 2021 · 0 comments
Assignees

Comments

@pchristensenB
Copy link

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)
image

IT would also work with files CSV like this

image (2)

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

3 participants