Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
gmartins
9 years agoExplorer | Level 3
Android API v2 - Can't build the sdk
Hi there, I'm currently trying to upgrade the sdk to v2, however, I'm struggling with simply building the repository in order to check the examples. I'm running ./gradlew install in the root ...
Qbert
9 years agoExplorer | Level 3
Hi Greg,
thanks a lot for your support. I managed to get the libraries included in Eclipse as external libs.
If somoeone else reads this it might be helpful to note that I got ClassNotFound runtime exceptions that could be removed by moving the newly added libs to the top of the Java Build Path (order and export) followed by a project clean. Not sure what really helped at the end.
I reach the point were I can authenticate and get my DropBox Client.
And with this back to the initial problem:
Is there a way to load a DropBox File into a local String. That is the use case I achieved with getFileStream. I am reading the input file stream in a String.
I cannot find a corresponding method. The example performs a download, which is unfortunately no option for me.
I am also struggeling to find a mapping between my DropBox filename (string) to the FileMetadata used in the Android example.
You mind pointing me in the right direction here.
P.S.: As you mentioned I had to kick out the Http3Requestor. This Requesor would be needed for what?
DbxRequestConfig requestConfig = DbxRequestConfig.newBuilder("qkeeper-v2")
//.withHttpRequestor(new OkHttp3Requestor(OkHttp3Requestor.defaultOkHttpClient()))
.build();Greg-DB
Dropbox Community Moderator
9 years agoQbert There's an example of downloading a file here. Or, you can call download to get a DbxDownloader and call DbxDownloader.getInputStream on it to get an input stream similar to how the v1 getFileStream method worked.
To get the FileMetadata for a particular file, you can call getMetadata.
The use of OkHttp3Requestor is optional, and is available if your app happens to already have the the OkHttp v3 library and you want to use it for making Dropbox API calls as well.
- Qbert9 years agoExplorer | Level 3
Hi Greg,
thanks again for your support. At the end I managed to update my app with my use case to the v2 Dropbox API.
I have used the methods and classes you mentioned. DbxDownloader and DbxUploader simplify the code quite a lot.
I also managed to load the Dropbox file directly into a String by providing my specialised OutputStream class.
The only remaining issue is that the authentication screen pops up everytime I initiate the Dropbex session. Not the login screen but screen asking to grant Dropbox access to the app. I must have probably misinterpreted the examples provided with respect to the authentication flow. I should check the preferences for the access token before creating the session.
And I am also wondering how to detect errors with startOAuth2Authentication.
Thanks for guiding me through the update process with your responsive, specific and very detailed help!!!
- Greg-DB9 years ago
Dropbox Community Moderator
It sounds like you're calling startOAuth2Authentication every time. You should only call that (or let the user trigger it) when necessary. You can see how the example app checks if it already has a token here.
The startOAuth2Authentication method can throw IllegalStateException, so you can catch that normally.
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!