iOS SDK: Get ID of folder give a folder name
Hi all,
Is there a way that given an expected folder name, such as "Test_Folder", that I can:
a) Check if "Test_Folder" exists
b) Get "Test_Folder"'s ID and keep it for later so that I can...
c) ...create a bunch of subdirectories and upload files into them
I am using the iOS SDK. My current solution is to just list all of the folders in the user's Box, and then find one that matches the name.
Sorry for the newb question.
-
You can use the Box API search endpoint to query a folder by name. If the search endpoint finds the folder, the response will include the folder's id.
Here is an example that shows how to make this call with the Box iOS SDK:
BOXContentClient *contentClient = [BOXContentClient defaultClient]; BOXSearchRequest *searchRequest = [contentClient searchRequestWithQuery:@"Test Folder" inRange:NSMakeRange(0, 1000)]; [searchRequest performRequestWithCompletion:^(NSArray *items, NSUInteger totalCount, NSRange range, NSError *error) { // If successful, items will be non-nil and contain BOXItem model objects; otherwise, error will be non-nil. }];
Please sign in to leave a comment.
Comments
1 comment