路径模式匹配/

时间:2014-07-07 18:59:31

标签: restkit dropbox-api sockit

我正在尝试为Dropbox metadata API的调用构建响应描述符。

使用Dropbox OS X SDK中的DBMetadata类,这是我的映射:

RKObjectMapping *metadataMapping;
metadataMapping = [RKObjectMapping mappingForClass:[DBMetadata class]];
[metadataMapping addAttributeMappingsFromDictionary:@{@"thumb_exists": @"thumbnailExists",
                                                      @"bytes"       : @"totalBytes",
                                                      @"modified"    : @"lastModifiedDate",
                                                      @"client_mtime": @"clientMtime",
                                                      @"path"        : @"path",
                                                      @"is_dir"      : @"isDirectory",
                                                      @"hash"        : @"hash",
                                                      @"size"        : @"humanReadableSize",
                                                      @"root"        : @"root",
                                                      @"icon"        : @"icon",
                                                      @"rev"         : @"rev",
                                                      @"revision"    : @"revision",
                                                      @"is_deleted"  : @"isDeleted"}];
[metadataMapping addRelationshipMappingWithSourceKeyPath:@"contents"
                                                 mapping:metadataMapping];

以下是我的回复描述符(尽管我很喜欢,但我无法使用:root:path,请参阅NOTE 1):

RKResponseDescriptor *metadataResponse;
metadataResponse = [RKResponseDescriptor responseDescriptorWithMapping:metadataMapping
                                                                method:RKRequestMethodGET
                                                           pathPattern:@"metadata/dropbox:path"
                                                               keyPath:nil
                                                           statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
[self.manager addResponseDescriptor:metadataResponse];

经理的设置为:

NSURL *baseAPIURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@/%@/", kDBProtocolHTTPS, kDBDropboxAPIHost, kDBDropboxAPIVersion]];
self.manager = [RKObjectManager managerWithBaseURL:baseAPIURL];
self.manager.requestSerializationMIMEType = RKMIMETypeJSON;

问题是@"metadata/dropbox:path"路径模式总是失败:

DBMetadata *root;
root = [[DBMetadata alloc] initWithDictionary:@{@"root": @"dropbox",
                                                @"path": @"/"}];
[self.manager getObject:root
                   path:@"metadata/dropbox/"
             parameters:@{@"list": @"false"}
                success:...
                failure:...];

结果:

  

E restkit.network:RKObjectRequestOperation.m:213 GET   ' https://api.dropbox.com/1/metadata/dropbox/?list=false' (200 OK / 0   对象)[request = 0.0957s mapping = 0.0000s total = 0.0968s]:错误   Domain = org.restkit.RestKit.ErrorDomain Code = 1001"无响应   描述符匹配加载的响应。"的UserInfo = 0x6000000ee900   {NSLocalizedFailureReason =从URL加载了200响应   ' https://api.dropbox.com/1/metadata/dropbox/?list=false',失败了   匹配所有(0)响应描述符:,   NSErrorFailingURLStringKey = https://api.dropbox.com/1/metadata/dropbox/?list=false,   NSErrorFailingURLKey = https://api.dropbox.com/1/metadata/dropbox/?list=false,   NSUnderlyingError = 0x6000000569b0"没有可映射的对象表示   在搜索的关键路径中找到。",keyPath = null,   NSLocalizedDescription =没有响应描述符与响应匹配   加载。}

但是如果我将响应描述符中的路径模式设置为静态字符串(@"metadata/dropbox/"),它就可以工作:

  

我restkit.network:RMObjectRequestOperation.m:220 GET   ' https://api.dropbox.com/1/metadata/dropbox/?list=false' (200 OK / 1   对象)[request = 0.1027s mapping = 0.0014s total = 0.1034s]

是否无法通过" /"作为路径模式参数?

我还注意到错误表明响应未能匹配所有(0)响应描述符。在这种情况下不应该是(1)吗?

0 个答案:

没有答案