Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
Bob S.15
9 years agoCollaborator | Level 9
migrating from API 1 to 2 - how do I know if I have OAuth 1 tokens?
I am finally getting around to updating my OLD apps from the original Dropbox IOS API to the new one. I'm looking at the migration guide, and the first thing it says is to check my OAuth tokens to see if they are version 1 or 2. How do I know which I have?
Also, the migration guide describes using the "endpoint" /oauth2/token_from_oauth1 to transition old tokens. So, I am coming to this from an ancient time -- what is an "endpoint", and is this 'token_from_oauth1' a function that you call from Objective-C in an iOS app? The documentation page I'm looking at only shows Python, Java, Ruby, and PHP examples, so maybe I'm not looking in the right place.
Is this where I should start? Is there a guide for upgrading an iOS app somewhere?
Also is this page current? It dates from March 2016, but then also there is a v1 deprecation warning at the top of it:
https://www.dropbox.com/developers-v1/core/sdks/ios
Thanks,
Bob
54 Replies
Replies have been turned off for this discussion
- Bob S.159 years agoCollaborator | Level 9
Hey Greg,
With the old API, when I got a file's metadata, the returned DBMetadata structure included the filename, the path, the revision, the total bytes, and the last modified date. Isn't that stuff commonly considered the metadata? With the new API, getMetadata seems like it only returns the filename and path, is that correct? How do I access that other information?
Thanks
Bob
- Greg-DB9 years ago
Dropbox Community Moderator
This information is still available, but it depends on the object type. The name and path are available on all DBFILESMetadata objects:
https://dropbox.github.io/dropbox-sdk-obj-c/api-docs/latest/Classes/DBFILESMetadata.html
Modified time, size, rev, etc. are available on DBFILESFileMetadata instances:
https://dropbox.github.io/dropbox-sdk-obj-c/api-docs/latest/Classes/DBFILESFileMetadata.html
(DBFILESFileMetadata is a sub-type of DBFILESMetadata.)
You can see an example of how to check and cast these types here:
https://github.com/dropbox/dropbox-sdk-obj-c#response-handling-edge-cases - Bob S.159 years agoCollaborator | Level 9
OK, thanks, I got it now.
Also - is it okay to use the pathDisplay variable as a replacement for the old API's 'path' variable? The docs say pathDisplay is only for display purposes, as if it might be incorrect sometimes. But the other option is 'pathLower' , which is a lower-case version. So what do you use if you just want the exact pathname, like what you had in the old API?
- Greg-DB9 years ago
Dropbox Community Moderator
Yes, v2's pathDisplay is the equivalent of v1's path. You should use that whenever you want to display the correctly cased version of the path. For the API calls themselves though, e.g., if you're taking the path from the metadata to then download the file, you should use pathLower. The Dropbox API is case-insensitive, and pathLower is the canonicalized version of the path. (Most of the time this doesn't matter, but there are a few edge cases that you can avoid by using pathLower when specifying paths in API calls.) - Bob S.159 years agoCollaborator | Level 9
If the API is case insensitive, what happens when you upload a file with capitalization, and then try to download it again later? Wouldn't it lose the capitalization? Like, if I upload from once device and download to another, then if I used pathLower to create the new file, I would lose the original capitalization...
One reason why these docs are so confusing to me, and why I asked that previous question, is that for example, getMetadata says it returns a DBFILESMetadata object. But if you go to the docs for that object, there is no indication that there are subclasses of that object for the various types -- file, folder, etc. How would I know that if you hadn't told me? Is there documentation I'm missing?
So that leads me to another question, sorry! If I use -getMetadata:includeMediaInfo:includeDeleted:includeHasExplicitSharedMembers:
then I assume you can tell whether the file/folder is deleted by the type of DBFILESMetadata object that is returned -- a DBFILESDeletedMetadata object, right? But then how do to tell if it was a file or a folder -- because normally you would check for a
DBFILESFolderMetadata or DBFILESFileMetadata object for that. ??
Finally, the getMetadata docs say this about the 'includeDeleted' argument:
"If true, DeletedMetadata will be returned for deleted file or folder, otherwise notFound in DBFILESLookupError will be returned." What does this mean? Say I have a path to a file that does exist, and I call getMetadata with 'includeDeleted' = true. Will I get both a DBFILESFileMetadata object in the return, as well as a 'notFound' in the DBFilesLookupError? And where would that DBFilesLookupError be? Would it be part of the returned DBFILESGetMetadataError or the DBRequestError?
Thanks
Bob
- Greg-DB9 years ago
Dropbox Community Moderator
The API is case-insensitive, but case-preserving. So when you upload a file with a certain casing, that will be preserved in pathDisplay, though you can reference that file with a lower-cased version of the path.
In the re-creation scenario you describe, you can certainly re-use pathDisplay to create it with the casing you want.
And thanks, that's good feedback regarding the sub-classes in the documentation. I'll send it along to the team.
If you use includeDeleted with getMetadata, the resulting DBFILESMetadata will be one of DBFILESFileMetadata, DBFILESFolderMetadata, DBFILESDeletedMetadata. Deleted entries are neither files nor folders though. They just indicate that there was previously something at that path. (That something could have, at different points in time, been a file and a folder.)
For getMetadata, if you set includeDeleted to true, for a deleted entry, the "result" will be a DBFILESDeletedMetadata. If you set includeDeleted to false, the "route error" will contain a DBFilesLookupError (nested in a DBFILESGetMetadataError.path, to be strictly accurate.) You won't get both though.
You can see an example of the separation of the result, route error, and error for an RPC call like this here:
https://github.com/dropbox/dropbox-sdk-obj-c#rpc-style-request
- Bob S.159 years agoCollaborator | Level 9
Okay -- thanks for all of this help!
I was wondering, is there any way to cause Dropbox errors intentionally for testing? For example I would like to test the various upload errors that might happen.
Bob
- Greg-DB9 years ago
Dropbox Community Moderator
No, there isn't a way to trigger various errors like that (short of actually producing the relevant conditions), but I'll pass this along as a feature request. - Bob S.159 years agoCollaborator | Level 9
Okay. Another question -- can I use
([DropboxClientsManager authorizedClient] != nil)
as a replacement for
[[DBSession sharedSession] isLinked]
? Or are those two not equivalent? Is there something better I should use?
- Greg-DB9 years ago
Dropbox Community Moderator
Yes, that's it.
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!