How can we get folder id based on folder name
回答済みWe are using box python sdk for uploading files, creating folders etc. We have a problem where we want to upload a file to a folder and that's taking a significant amount of time.
Let's say we have a folder structure like : box-com/policyme/pm-folder-1234, etc
Now let's say, we have over 10k folders inside policyme
Now We want to upload a file to a folder let's say, pm-folder-5000 ( ex: box-com/policyme/pm-folder-5000)
What we need is a way to retrieve the folder id based on the folder-name (either via box python SDKs or via box rest api )
1. send folder-name to box ( ex: pm-folder-5000)
2. box returns folder id (ex: 1xy115000 )
We are using https://github.com/box/box-python-sdk/blob/main/docs/usage/folders.md#get-the-items-in-a-folder logic to retrieve the folder-id by iterating over all the folders and this is taking a lot of time, Rather we need to GET-FOLDER ID-FROM-FOLDER-NAME instead.
-
Found the solution on https://developer.box.com/reference/get-search/
We can use the search api to search for folders and use the query parameter to filter based on folder_namesitems = client.search().query(query='TEST QUERY', type='file', limit=100, file_extensions=['pdf', 'doc'])
サインインしてコメントを残してください。
コメント
1件のコメント