Get Audio Files From Dropbox iOS Core API -
i need list audio files user's dropbox. configured app on developer console have corresponding permissions. authenticated user, can retrieve directories want method goes every folder , list audiofiles can find. method have 3 concerns.
- the method kind of slow (recursive)
i getting 2 random errors (probably due multiple request per second)
listing random folder.
2015-06-02 12:44:52.634 podbox[9038:2918749] error loading metadata: error domain=dropbox.com code=503 "the operation couldn’t completed. (dropbox.com error 503.)" userinfo=0x170270780 {path=/ios dev/passbook/signpass/signpass.xcodeproj/xcuserdata/gsteele.xcuserdatad, error=rate limiting oauth_accesses_per_access_token}
accessing music
2015-06-02 12:44:32.665 podbox[9038:2918749] error loading metadata: error domain=nsurlerrordomain code=-1001 "the operation couldn’t completed. (nsurlerrordomain error -1001.)" userinfo=0x17047cf00 {path=/music/blink 182/unknown album}
i know im getting mp3 files. there way media files without checking pathextensions?
currently trying this:
- (void)restclient:(dbrestclient *)client loadedmetadata:(dbmetadata *)metadata { if (metadata.isdirectory) { (dbmetadata *file in metadata.contents) { if (file.isdirectory) { [self.restclient loadmetadata:file.path]; } else if ([file.path.pathextension isequaltostring:@"mp3"]){ nslog(@" %@", file.filename); } } } }
you awesome.
the metadata method inefficient when used recursively this, instead, you'll want use loaddelta
method:
/* loads list of files (represented dbdeltaentry objects) have changed since cursor generated */ - (void)loaddelta:(nsstring *)cursor; - (void)restclient:(dbrestclient*)client loadeddeltaentries:(nsarray *)entries reset:(bool)shouldreset cursor:(nsstring *)cursor hasmore:(bool)hasmore; - (void)restclient:(dbrestclient*)client loaddeltafailedwitherror:(nserror *)error;
there's blog post here (albeit python) covers basic idea of how use this:
https://blogs.dropbox.com/developers/2013/12/efficiently-enumerating-dropbox-with-delta/
this should more efficient method in case, resolving first 2 issues.
it doesn't offer way filter specific file types on server though, you'll need client-side.
Comments
Post a Comment