Synny
Synny

Reputation: 542

Uploading file to a specific folder with Box api- Objective-c iOS

I can successfuly upload files to root of box storage using the "fileUploadRequestToFolderWithID:BoxAPIFolderIDRoot " key but I would like to upload file to a specific folder that I've created using :

BOXContentClient *contentClient = [BOXContentClient defaultClient];
BOXFolderCreateRequest *folderCreateRequest = [contentClient folderCreateRequestWithName:@"New Folder" parentFolderID:BoxAPIFolderIDRoot];
[folderCreateRequest performRequestWithCompletion:^(BOXFolder *folder, NSError *error) {
    // If successful, folder will be non-nil and represent the newly created folder on Box; otherwise, error will be non-nil.
}];

How could I retrieve the folder ID for uploading file to it ?

Thanks in advance !

Upvotes: 0

Views: 465

Answers (1)

Murtza Manzur
Murtza Manzur

Reputation: 1214

The Box iOS SDK refers to the folder's ID as the folder's modelID. You can access the modelID property of the folder within the completion block of folderCreateRequest. For example:

BOXContentClient *contentClient = [BOXContentClient defaultClient];
BOXFolderCreateRequest *folderCreateRequest = [contentClient folderCreateRequestWithName:@"New Folder" parentFolderID:BoxAPIFolderIDRoot];
[folderCreateRequest performRequestWithCompletion:^(BOXFolder *folder, NSError *error) {
NSString *folderID = folder.modelID;
}];

Upvotes: 1

Related Questions