We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
mms
7 years agoHelpful | Level 6
Nil fileUrlsToBatchResultEntries response when setting template name and value to DBFILESCommitInfo
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.
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.
2 Replies
- Greg-DB7 years ago
Dropbox Community Moderator
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);
- mms7 years agoHelpful | Level 6
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.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!