I need to upload a file to a folder inside box. I chose python to implement this logic at server side.
But I find that box-sdk python doesn't supports to check if a folder exists with its name? Is there any way to check if a folder exists just with its name rather than Id ?
There in fact a way to search by exact name, however sometimes it could be an access issue. consider this python script:
Resulting in:
This establishes that the security context of the script impersonating a user, can list the contents of the root folder and it has an assortment of files, folder and even a web link.
Now let's search the string 'Box' and return only folders:
Resulting in:
At least we only got folders this time...
So what is going on here?
Box search looks for the string in many places, including, name, description, tags, and inside the content it self.
Note that it found folders that are not direct descendants of the root folder, since we did not specify an ancestor folder. However it can be done, and might be useful for your use case. Just specify the ancestor_folders="a_folder_id" as a query argument.
Let's limit the search of the string only to name:
Resulting in:
As you can see these have the string Box in the name. Finally we can request an exact match for the string in the name:
Final result:
Of course if in the example if 'My Box Notes' existed in another folder level it would show up multiple times.