cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Nil fileUrlsToBatchResultEntries response when setting template name and value to DBFILESCommitInfo

Nil fileUrlsToBatchResultEntries response when setting template name and value to DBFILESCommitInfo

mms
Helpful | Level 6
Go to solution

 

Hello there.

I am trying to set a property custom property to a file that I am uploading to User's folder with the name 'name' and value 'value', with teamplate '/templateId'. When I add the following I get a nil fileUrlsToBatchResultEntries and as consequence nil result, however the file is indeed uploaded to the applications' folder.

        NSMutableDictionary<NSURL *, DBFILESCommitInfo *> *uploadFilesUrlsToCommitInfo = [NSMutableDictionary new];
        NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:localFilePath error:nil];
        NSArray *propertyGroupArray = [NSArray arrayWithObjects:[[DBFILEPROPERTIESPropertyGroup alloc] initWithTemplateId:@"/templateId" fields:[NSArray arrayWithObjects:[[DBFILEPROPERTIESPropertyField alloc] initWithName:@"name" value:@"value"], nil]], nil];
        DBFILESCommitInfoWithProperties *commitInfo = [[DBFILESCommitInfoWithProperties alloc] initWithPath:cloudFilePath mode:[[DBFILESWriteMode alloc] initWithOverwrite] autorename:[NSNumber numberWithBool:NO] clientModified:attributes[NSFileCreationDate] mute:[NSNumber numberWithBool:YES] propertyGroups:nil strictConflict:[NSNumber numberWithBool:YES]]
        [uploadFilesUrlsToCommitInfo setObject:commitInfo forKey:[NSURL fileURLWithPath:localFilePath]];
        [client.filesRoutes batchUploadFiles:uploadFilesUrlsToCommitInfo queue:nil progressBlock: {} responseBlock:^(NSDictionary<NSURL *,DBFILESUploadSessionFinishBatchResultEntry *> *fileUrlsToBatchResultEntries, DBASYNCPollError *finishBatchRouteError, DBRequestError *finishBatchRequestError, NSDictionary<NSURL *,DBRequestError *> *fileUrlsToRequestErrors){         
                DBFILESMetadata *dbFilesMetadata = nil;
                DBFILESUploadSessionFinishBatchResultEntry *result = fileUrlsToBatchResultEntries[[NSURL fileURLWithPath:localFilePath]];
                if (result) {
                    if (result.tag == DBFILESUploadSessionFinishBatchResultEntrySuccess)
                        dbFilesMetadata = result.success;
                    else
                        aError = [self errorFromRouteError:finishBatchRouteError requestError:finishBatchRequestError];
                } else
                    aError = [self errorFromRouteError:finishBatchRouteError requestError:finishBatchRequestError];
                success = (dbFilesMetadata != nil);
        }];

What am I doing wrong when trying to set a property name and value to the file that I want to upload, please?

Looking forward to your response.

 

1 Accepted Solution

Accepted Solutions

mms
Helpful | Level 6
Go to solution

I found the solution following the source:

https://www.dropboxforum.com/t5/API-Support-Feedback/File-properties/td-p/288255

The problem was that I was trying to set the property while having a folder access only.

Cheers.

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution

If the file does get uploaded, fileUrlsToBatchResultEntries shouldn't be nil, so we'll be happy to help look into it. Is this is actual code you're running though, or was it edited for the post? I ask because it looks like you may be missing some curly brackets. Also, it looks like you're not using the propertyGroupArray anyway.

To begin debugging this, it may be helpful to start by just printing out all of the values given to the response block, e.g.:

 

NSLog(@"fileUrlsToBatchResultEntries: %@", fileUrlsToBatchResultEntries);
NSLog(@"finishBatchRouteError: %@", finishBatchRouteError);
NSLog(@"finishBatchRequestError: %@", finishBatchRequestError);
NSLog(@"fileUrlsToRequestErrors: %@", fileUrlsToRequestErrors);

 

 

mms
Helpful | Level 6
Go to solution

I found the solution following the source:

https://www.dropboxforum.com/t5/API-Support-Feedback/File-properties/td-p/288255

The problem was that I was trying to set the property while having a folder access only.

Cheers.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    mms Helpful | Level 6
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?