Giter Site home page Giter Site logo

dropbox / dropbox-sdk-java Goto Github PK

View Code? Open in Web Editor NEW
586.0 64.0 444.0 109.58 MB

A Java library for the Dropbox Core API.

Home Page: https://www.dropbox.com/developers/documentation/java

License: MIT License

Java 98.61% Python 0.98% Shell 0.01% Kotlin 0.41%

dropbox-sdk-java's Introduction

Dropbox Core SDK for Java

GitHub Maven Central GitHub Release Date

A Java library to access Dropbox's HTTP-based Core API v2. This SDK also supports the older Core API v1, but that support will be removed at some point.

License: MIT

Documentation: Javadocs

Setup

Java Version

The current release of Dropbox SDK Java supports Java 8+.

Add a dependency on the Dropbox Java SDK to your project

If you're using Maven, then edit your project's "pom.xml" and add this to the <dependencies> section:

<dependency>
    <groupId>com.dropbox.core</groupId>
    <artifactId>dropbox-core-sdk</artifactId>
    <version>7.0.0</version>
</dependency>

If you are using Gradle, then edit your project's "build.gradle" and add this to the dependencies section:

dependencies {
    // ...
    implementation 'com.dropbox.core:dropbox-core-sdk:7.0.0'
}

You can also download the Java SDK JAR and and its required dependencies directly from the latest release page. Note that the distribution artifacts on the releases pages do not contain optional dependencies.

Dropbox for Java tutorial

A good way to start using the Java SDK is to follow this quick tutorial. Just make sure you have the Java SDK installed first!

Register a Dropbox API app

To use the Dropbox API, you'll need to register a new app in the App Console. Select Dropbox API app and choose your app's permission. You'll need to use the app key created with this app to access API v2.

Link an account

In order to make calls to the API, you'll need an instance of the Dropbox object. To instantiate, pass in the access token for the account you want to link. (Tip: You can generate an access token for your own account through the App Console).

import com.dropbox.core.DbxException;
import com.dropbox.core.DbxRequestConfig;
import com.dropbox.core.v2.DbxClientV2;

public class Main {
    private static final String ACCESS_TOKEN = "<ACCESS TOKEN>";

    public static void main(String args[]) throws DbxException {
        // Create Dropbox client
        DbxRequestConfig config = DbxRequestConfig.newBuilder("dropbox/java-tutorial").build();
        DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);
    }
}

Test it out to make sure you've linked the right account:

// Get current account info
FullAccount account = client.users().getCurrentAccount();
System.out.println(account.getName().getDisplayName());

Try some API requests

You can use the Dropbox object you instantiated above to make API calls. Try out a request to list the contents of a folder.

// Get files and folder metadata from Dropbox root directory
ListFolderResult result = client.files().listFolder("");
while (true) {
    for (Metadata metadata : result.getEntries()) {
        System.out.println(metadata.getPathLower());
    }

    if (!result.getHasMore()) {
        break;
    }

    result = client.files().listFolderContinue(result.getCursor());
}

Try uploading a file to your Dropbox.

// Upload "test.txt" to Dropbox
try (InputStream in = new FileInputStream("test.txt")) {
    FileMetadata metadata = client.files().uploadBuilder("/test.txt")
        .uploadAndFinish(in);
}

Full Example Snippet

import com.dropbox.core.DbxException;
import com.dropbox.core.DbxRequestConfig;
import com.dropbox.core.v2.DbxClientV2;
import com.dropbox.core.v2.files.FileMetadata;
import com.dropbox.core.v2.files.ListFolderResult;
import com.dropbox.core.v2.files.Metadata;
import com.dropbox.core.v2.users.FullAccount;

import java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;

public class Main {
    private static final String ACCESS_TOKEN = "<ACCESS TOKEN>";

    public static void main(String args[]) throws DbxException, IOException {
        // Create Dropbox client
        DbxRequestConfig config = DbxRequestConfig.newBuilder("dropbox/java-tutorial").build();
        DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);

        // Get current account info
        FullAccount account = client.users().getCurrentAccount();
        System.out.println(account.getName().getDisplayName());

        // Get files and folder metadata from Dropbox root directory
        ListFolderResult result = client.files().listFolder("");
        while (true) {
            for (Metadata metadata : result.getEntries()) {
                System.out.println(metadata.getPathLower());
            }

            if (!result.getHasMore()) {
                break;
            }

            result = client.files().listFolderContinue(result.getCursor());
        }

        // Upload "test.txt" to Dropbox
        try (InputStream in = new FileInputStream("test.txt")) {
            FileMetadata metadata = client.files().uploadBuilder("/test.txt")
                .uploadAndFinish(in);
        }
    }
}

Full examples

Some more complete examples can be found here:

To try out running these examples, please follow the instructions below.

Save your Dropbox API key

Save your Dropbox API key to a JSON file called, say, "test.app":

{
  "key": "Your Dropbox API app key",
  "secret": "Your Dropbox API app secret"
}

App key and secret can be found in you app page in App Console.

Building from source

git clone https://github.com/dropbox/dropbox-sdk-java.git
cd dropbox-sdk-java
./update-submodules    # also do this after every "git checkout"
./gradlew build # requires `python` command to use Python 3.9, pip dropbox

The output will be in "build/".

Running the examples

  1. Follow the instructions in the "Build from source" section above.
  2. Save your Dropbox API key in a file called "test.app". See: Save your Dropbox API key, above.
  3. Compile and install the SDK into your local maven repo: ./gradlew build
  4. To compile all the examples: cd examples/ && ./gradlew classes
  5. To compile just one example: cd examples/ && ./gradlew :<example-name>:classes

authorize

This example runs through the OAuth 2 authorization flow.

cd examples
./run authorize test.app test.auth

This produces a file named "test.auth" that has the access token. This file can be passed in to the other examples.

account-info

A simple example that fetches and displays information about the account associated with the access token.

cd examples
./run account-info test.auth

(You must first generate "test.auth" using the "authorize" example above.)

longpoll

An example of how to watch for changes in a Dropbox directory.

cd examples
./run longpoll test.auth "/path/to/watch"

(You must first generate "test.auth" using the "authorize" example above.)

upload-file

Uploads a file to Dropbox. The example includes regular and chunked file uploads.

cd examples
./run upload-file test.auth local-path/file.txt /dropbox-path/file.txt

(You must first generate "test.auth" using the "authorize" example above.)

web-file-browser

A tiny web app that runs through the OAuth 2 authorization flow and then uses Dropbox API calls to let the user browse their Dropbox files.

Prerequisite: In the Dropbox API app configuration console, you need to add "http://localhost:5000/dropbox-auth-finish" to the list of allowed redirect URIs.

cd examples
./run web-file-browser 5000 test.app web-file-browser.db

Running the integration tests

  1. Run through the authorize example above to get a "test.auth" file.
  2. ./gradlew -Pcom.dropbox.test.authInfoFile=<path-to-test.auth> integrationTest

To run individual tests, use the --tests gradle test filter:

./gradlew -Pcom.dropbox.test.authInfoFile=<path-to-test.auth> integrationTest --tests '*.DbxClientV1IT.testAccountInfo'

Usage on Android

Edit your project's "build.gradle" and add the following to the dependencies section:

dependencies {
    // ...
    implementation 'com.dropbox.core:dropbox-core-sdk:7.0.0'
    implementation 'com.dropbox.core:dropbox-android-sdk:7.0.0'
}

If you leverage jettifier and see the following errors then please add android.jetifier.ignorelist = jackson-core,fastdoubleparser to your gradle.properties file.

Failed to transform jackson-core-2.15.0.jar (com.fasterxml.jackson.core:jackson-core:2.15.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.

The Android code in this SDK is written in Kotlin (as of 5.4.x) and Kotlin is now a runtime dependency. If you do not already have Kotlin in your project, you will need to add implementation("org.jetbrains.kotlin:kotlin-stdlib:1.6.21") to your dependencies block in order to avoid a runtime exception.

If the official Dropbox App is installed, it will attempt to use it to do authorization. If it is not, a web authentication flow is launched in-browser.

Use the methods in the Auth to start an authentication sessions.

Please look at the examples/android sample app for usage as well.

Required Configuration for Authentication on Android

The following below is required configuration when using the SDK on Android.

AndroidManifest.xml

Add these following pieces to your AndroidManifest.xml to use Dropbox for Authentication in Android.

Add AuthActivity to the manifest

Use your Dropbox APP Key in place of dropboxKey below. You need to add the AuthActivity entry, and it's associated intent-filter.

<manifest>
    ...
    <application>
        <activity
            android:name="com.dropbox.core.android.AuthActivity"
            android:exported="true"
            android:configChanges="orientation|keyboard"
            android:launchMode="singleTask">
            <intent-filter>
                <data android:scheme="db-${dropboxKey}" />
        
                <action android:name="android.intent.action.VIEW" />
        
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            
            <!-- Additional intent-filter required as a workaround for Apps using targetSdk=33 until the fix in the Dropbox app is available to all users. -->
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>
    ...
</manifest>

Your activity starting the authorization flow should also configured with android:launchMode="singleTask". Also, if that activity is configured with android:taskAffinity, then the AuthActivity should also configured with the same task affinity, such that authorization result can be passed back to your activity.

๐ŸšจThere is a known issue regarding apps with targetSdk=33 regarding app-to-app authentication when the Dropbox App is installed ๐Ÿšจ A fix is being worked on and will be released in an upcoming version of the Dropbox Mobile App.

Add Dropbox package to queries

Additionally, you need to allow queries from the Dropbox official app for verification during the app-to-app authentication flow.

<manifest>
    ...
    <queries>
        <package android:name="com.dropbox.android" />
    </queries>
    ...
</manifest>

FAQ

When I use OkHttp3Requestor in DbxRequestConfig, I get errors like 'class file for okhttp3.OkHttpClient not found'

The dependency of OKHttp/OKHttp3 is optional. You should add them, only if you explicitly want to use it as the http requestor.

Example in Gradle:

dependencies {
    // ...
    api 'com.squareup.okhttp3:okhttp:4.0.0'
}

When I use the bundle JAR with some OSGi containers within an OSGi subsystem, I get a "Missing required capability" error

The JAR's manifest has the following line:

Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=11))"

Most OSGi containers should provide this capability. Unfortunately, some OSGi containers don't do this correctly and will reject the bundle JAR in the OSGi subsystem context.

As a workaround, you can build your own version of the JAR that omits the "osgi.ee" capability by running:

./gradlew clean
./gradlew -Posgi.bnd.noee=true :core:jar

(This is equivalent to passing the "-noee" option to the OSGi "bnd" tool.)

Another workaround is to tell your OSGi container to provide that requirement: StackOverflow answer.

Does this SDK require any special ProGuard rules for shrink optimizations?

The only ProGuard rules necessary are for the SDK's required and optional dependencies. If you encounter ProGuard warnings, consider adding the following "-dontwarn" directives to your ProGuard configuration file:

-dontwarn okio.**
-dontwarn okhttp3.**
-dontwarn com.squareup.okhttp.**
-dontwarn com.google.apphosting.**
-dontwarn com.google.appengine.**
-dontwarn com.google.protos.cloud.sql.**
-dontwarn com.google.cloud.sql.**
-dontwarn javax.activation.**
-dontwarn javax.mail.**
-dontwarn javax.servlet.**
-dontwarn org.apache.**

How do I enable certificate pinning?

As of version 7.0.0, the SDK no longer provides certificate pinning by default. We provide hooks for you to run each of your requests with your own SSLSocketFactory or CertificatePinner. To provide this to your calls, you can use any of the requestors provided.

Note: If you were previously using SSLConfig, this is no longer available. You can view the source in git history but we no longer provide any default certificate pinning or any other configuration.

Using StandardHttpRequestor

StandardHttpRequestor.Config customConfig = StandardHttpRequestor.Config.DEFAULT_INSTANCE.copy()
        .withSslSocketFactory(mySslSocketFactory)
        .build();
StandardHttpRequestor requestor = new StandardHttpRequestor(customConfig);

Using OkHttp3Requestor

See: CertificatePinner

okhttp3.OkHttpClient httpClient = OkHttp3Requestor.defaultOkHttpClientBuilder()
        .certificatePinner(myCertificatePinner)
        .build();

Using OkHttpRequestor

See: CertificatePinner

OkHttpClient httpClient = OkHttpRequestor.defaultOkHttpClient().clone()
        .setCertificatePinner(myCertificatePinner)
        .build();

dropbox-sdk-java's People

Contributors

andrewhaigh avatar andrioli avatar cakoose avatar changusmc avatar chris-mitchell avatar devpalacio avatar eyousefi avatar greg-db avatar handstandsam avatar hronom avatar idunnololz avatar jiuyangzhao avatar joshafeinberg avatar julianlocke avatar lchen8 avatar northnose avatar pcj avatar rallat avatar rharter avatar richardtitze avatar risforrob avatar scobbe avatar sdumont2 avatar tyvsmith avatar vjkoskela avatar wclausen avatar wdziemia avatar xcatg avatar yufeig avatar zjiuyang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dropbox-sdk-java's Issues

"String 'path' does not match pattern" error for a path returned by Dropbox itself

In my app I'm doing this:

String path = entry.getPathLower();
DbxDownloader<FileMetadata> downloader = mDbxClient.files().download(path);

Where entry is a com.dropbox.core.v2.filesFileMetadata instance returned by the SDK using listFolderBuilder(). In Crashlytics I'm seeing IllegalArgumentException errors:

IllegalArgumentException: String 'path' does not match pattern'.

Which are being thrown from the constructor of com.dropbox.core.v2.filesDownloadArg:

if (!java.util.regex.Pattern.matches("((/|id:).*)|(rev:[0-9a-f]{9,})", path)) {
    throw new IllegalArgumentException("String 'path' does not match pattern");
}

The issue: Dropbox appears to be returning metadata objects with an invalid path. It doesn't occur that often but it's neither rare. Also, users get this error multiple times, so it doesn't seem to happen sporadically.

In the logs I'm receiving I don't see any special characters or something like that, but it could be that Crashlytics strips them out. I've had some issues with uploading where users managed to get \n characters inside the filename, perhaps the SDK has a similar issue?

How does the search endpoint work? Will this endpoint support regex?

I seems that the it only returns matches where the word begings with the keyword by subtituting non-alphanumeric for space. I can find "Get Started with Dropbox.pdf" by searching the letter 'g' but i can't find it by searching 'e' (the second letter). I doesn't seem to provide result for contains keyword.

  1. Is my observation correct?
  2. Do you plan to support regex?

DbxException.RetryLater is thrown for both rate limit error and transient error.

In the core docs (https://www.dropbox.com/developers/core/docs) for error code 503 it advises to check the "Retry-After" header to determine if you are being rate limited or if you are getting a transient error. In the rate limit case "later" should be much later, but in the transient error case "later" should be now.

DbxException.RetryLater does not provide a way to check if it is the "retry later, later" case or the "retry later, now" case.

It would be helpful if there were separate Exceptions like DbxException.RateLimit and DbxException.TransientError. Or if DbxException.RetryLater had a method like getRetryAfter() to get more details.

/list_folder/longpoll throws Exception

Calling DbxFiles.listFolderLongpoll throws exception:

com.dropbox.core.DbxException$BadRequest: Error in call to API function "files/list_folder/longpoll": Your request includes an Authorization header, but this function does not use it.
at com.dropbox.core.DbxRequestUtil.unexpectedStatus(DbxRequestUtil.java:262)
at com.dropbox.core.v2.DbxRawClientV2.rpcStyle(DbxRawClientV2.java:95)
at com.dropbox.core.v2.DbxFiles.listFolderLongpoll(DbxFiles.java:7678)
at com.dropbox.core.v2.DbxFiles.listFolderLongpoll(DbxFiles.java:7705)

note: Looking at the source code, it seems indeed that listFolderLongpoll includes access token in the request which this is contrary to docs for /list_folder/longpoll endpoint.

Apache HTTP in Android SDK

The Android SDK uses the Apache HTTP client from the Android platform. In Android API 23 the apache client is no longer available. This produces compile errors if the Dropbox SDK is included in a project targeting the latest version of Android.

I couldn't find the Android SDK on github anywhere so I am reporting here.

Emoji in the file name

SDK throws error if the file name contains an Unicode emoji chars

Error in call to API function "files/upload": path: invalid path: character at index X: not part of the Unicode Basic Multilingual Plane

I don't think it is SDK's responsibility to sanitize file names. I am just posting it for other developers who might come across with the same issue

JSON parser alternatives

Is it possible to exchange the JSON parser which the Dropbox SDK uses?

Right now it has a hard dependency on Jackson, however my project is already using gson and it would be beneficial to re-use the same dependency.

This would save another 2000 methods (from Jackson) or 1000 from gson. (dex method count).

BitmapFactory.decodeStream() returns null for getPreviewUrl()

I am requesting the sharing preview Url as follows:
dbxClient.sharing().getFileMetadata(filePath).getPreviewUrl();

The url I get back is:
url = https://www.dropbox.com/scl/fi/f00yrcxcj4i9en80fl7ty

I am trying to get the bitmap for this url as follows:
bis = new BufferedInputStream(new URL(url).openConnection().getInputStream(), 8192)

bitmap = BitmapFactory.decodeStream(bis)

Unfortunately, I am getting back a null bitmap.
Any ideas as to why this is happening, or what I am doing wrong?

Note: new URL(url).openConnection().getResponseCode() < 300 for the above url

No way to set force_reapprove for DbxWebAuth

I don't see a way to set force_reapprove in the java sdk when going through web auth.

(maybe it's possible by injecting a HttpRequestor into DbxRequestConfig, but I didn't particularly want to start down that road)

Raw file uploads/downloads should implement Closeable

I have written a Java 7 FileSystem over DropBox which uses this API (version 1.7.7).

I've had some trouble when opening streams for file download and upload, since DbxClient.Uploader and DbxClient.Downloader do not implement Closeable; I've had to work around these with these two classes:

Moreover, as far as uploads are concerned, I always use a chuncked encoder, and the behaviour vastly differs from that of a non chuncked encoder in spite of the fact that they implement the same methods. This is quite confusing.

Is there a plan to provide alternatives to these two methods which implement Closeable and throw IOExceptions instead of throwing unchecked exceptions like they currently do?

Proguard issue of API ver 2.0.5

Some details: https://www.dropboxforum.com/hc/en-us/community/posts/206959906-Java-API-failure-after-Proguard-handling

Hi,

I found that if I use the recommendation proguard setting, i.e.

-dontwarn okhttp3.**
-dontwarn com.squareup.okhttp.**
-dontwarn com.google.appengine.**
-dontwarn javax.servlet.**`

The error will appear. All API throw same exception: Error in call to API function "users/API_PARAM": Invalid authorization value in HTTP header "Authorization": "Bearer". Expecting "Bearer "

06-15 10:05:00.623 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: java.util.concurrent.ExecutionException: com.dropbox.core.BadRequestException: Error in call to API function "users/get_current_account": Invalid authorization value in HTTP header "Authorization": "Bearer". Expecting "Bearer ".
06-15 10:05:00.623 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at java.util.concurrent.FutureTask.report(FutureTask.java:94)
06-15 10:05:00.623 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at java.util.concurrent.FutureTask.get(FutureTask.java:164)
06-15 10:05:00.623 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at hk.com.fgoproduction.getdroplets.Lib.Common.ThisApplication.runOnBgAndJoin(ThisApplication.kt:58)
06-15 10:05:00.623 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at hk.com.fgoproduction.getdroplets.Activity.MainActivity.threadExec(MainActivity.kt:187)
06-15 10:05:00.623 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at hk.com.fgoproduction.getdroplets.Activity.MainActivity.dropboxStatus(MainActivity.kt:176)
06-15 10:05:00.623 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at hk.com.fgoproduction.getdroplets.Activity.MainActivity.testAccessToken(MainActivity.kt:61)
06-15 10:05:00.623 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at hk.com.fgoproduction.getdroplets.Activity.MainActivity.onCreate(MainActivity.kt:43)
06-15 10:05:00.623 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at android.app.Activity.performCreate(Activity.java:6237)
06-15 10:05:00.623 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
06-15 10:05:00.623 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
06-15 10:05:00.623 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
06-15 10:05:00.623 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at android.app.ActivityThread.-wrap11(ActivityThread.java)
06-15 10:05:00.623 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
06-15 10:05:00.623 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
06-15 10:05:00.623 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at android.os.Looper.loop(Looper.java:148)
06-15 10:05:00.623 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5417)
06-15 10:05:00.623 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at java.lang.reflect.Method.invoke(Native Method)
06-15 10:05:00.623 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
06-15 10:05:00.624 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
06-15 10:05:00.624 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: Caused by: com.dropbox.core.BadRequestException: Error in call to API function "users/get_current_account": Invalid authorization value in HTTP header "Authorization": "Bearer". Expecting "Bearer ".
06-15 10:05:00.624 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at com.dropbox.core.DbxRequestUtil.unexpectedStatus(DbxRequestUtil.java:285)
06-15 10:05:00.624 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at com.dropbox.core.v2.DbxRawClientV2$1.execute(DbxRawClientV2.java:107)
06-15 10:05:00.624 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at com.dropbox.core.v2.DbxRawClientV2.executeRetriable(DbxRawClientV2.java:252)
06-15 10:05:00.624 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at com.dropbox.core.v2.DbxRawClientV2.rpcStyle(DbxRawClientV2.java:97)
06-15 10:05:00.624 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at com.dropbox.core.v2.users.DbxUserUsersRequests.getCurrentAccount(DbxUserUsersRequests.java:120)
06-15 10:05:00.624 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at hk.com.fgoproduction.getdroplets.DropboxAPI.AFile.isDropboxOk(AFile.kt:139)
06-15 10:05:00.624 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at hk.com.fgoproduction.getdroplets.Activity.MainActivity$dropboxStatus$1.run(MainActivity.kt:176)
06-15 10:05:00.624 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
06-15 10:05:00.624 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
06-15 10:05:00.624 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
06-15 10:05:00.624 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
06-15 10:05:00.624 2823-2823/hk.com.fgoproduction.getdroplets W/System.err: at java.lang.Thread.run(Thread.java:818)

But if I add two proguard rules instead, all errors disappear.

-dontobfuscate
-dontshrink

Either one is lacked will cause the errors appear again. Any idea about on this instead of not using proguard?
I think proguard with dontobfuscate and dontshrink is useless at all.

java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

Got the following exception when uploading to Dropbox. Using the latest 2.0.4 SDK. Any help is appreciated. Thanks.

Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:328)
at com.android.okhttp.internal.http.SocketConnector.connectTls(SocketConnector.java:103)
at com.android.okhttp.Connection.connect(Connection.java:143)
at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:185)
at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128)
at com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:341)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:437)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:114)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:245)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java)
at com.dropbox.core.http.StandardHttpRequestor$Uploader.getOutputStream(StandardHttpRequestor.java:108)
at com.dropbox.core.http.StandardHttpRequestor$Uploader.(StandardHttpRequestor.java:99)
at com.dropbox.core.http.StandardHttpRequestor.startPost(StandardHttpRequestor.java:71)
at com.dropbox.core.http.StandardHttpRequestor.startPost(StandardHttpRequestor.java:26)
at com.dropbox.core.DbxRequestUtil.startPostRaw(DbxRequestUtil.java:219)

"No authentication challenges found" during listFolderContinue()

I've been getting these error reports:

Caused by com.dropbox.core.w: No authentication challenges found
   at com.dropbox.core.DbxRequestUtil.startPostRaw(DbxRequestUtil.java:238)
   at com.dropbox.core.v2.DbxRawClientV2$1.execute(DbxRawClientV2.java:100)
   at com.dropbox.core.v2.DbxRawClientV2.addAuthHeaders(DbxRawClientV2.java:252)
   at com.dropbox.core.v2.DbxRawClientV2.addAuthHeaders(DbxRawClientV2.java:97)
   at com.dropbox.core.v2.files.DbxUserFilesRequests.listFolderContinue(DbxUserFilesRequests.java:688)
   at com.dropbox.core.v2.files.DbxUserFilesRequests.listFolderContinue(DbxUserFilesRequests.java:716)
   [..]
Caused by java.io.IOException: No authentication challenges found
   at libcore.net.http.HttpURLConnectionImpl.getAuthorizationCredentials(HttpURLConnectionImpl.java:436)
   at libcore.net.http.HttpURLConnectionImpl.processAuthHeader(HttpURLConnectionImpl.java:416)
   at libcore.net.http.HttpURLConnectionImpl.processResponseHeaders(HttpURLConnectionImpl.java:365)
   at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:301)
   at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495)
   at libcore.net.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:134)
   at com.dropbox.core.http.StandardHttpRequestor.toResponse(StandardHttpRequestor.java:49)
   at com.dropbox.core.http.StandardHttpRequestor.access$000(StandardHttpRequestor.java:28)
   at com.dropbox.core.http.StandardHttpRequestor$Uploader.finish(StandardHttpRequestor.java:157)
   at com.dropbox.core.DbxRequestUtil.startPostRaw(DbxRequestUtil.java:233)
   at com.dropbox.core.v2.DbxRawClientV2$1.execute(DbxRawClientV2.java:100)
   at com.dropbox.core.v2.DbxRawClientV2.addAuthHeaders(DbxRawClientV2.java:252)
   at com.dropbox.core.v2.DbxRawClientV2.addAuthHeaders(DbxRawClientV2.java:97)
   at com.dropbox.core.v2.files.DbxUserFilesRequests.listFolderContinue(DbxUserFilesRequests.java:688)
   at com.dropbox.core.v2.files.DbxUserFilesRequests.listFolderContinue(DbxUserFilesRequests.java:716)
   [..]

My code:

mDbxClient.files().listFolderContinue(cursor);

Any idea what could cause this?

Malformed RFC 5646 language tag

After updating to 2.0.4 I am seeing the following error when calling dbxClientV2.files().listFolder

com.dropbox.core.BadRequestException: HTTP header "Dropbox-API-User-Locale": Malformed RFC 5646 language tag: "de_DE": Invalid character at index 2: "_".  (RFC 5646 specifies "-" as the separator, not "_".)
    at com.dropbox.core.DbxRequestUtil.unexpectedStatus(DbxRequestUtil.java:274) ~[dropgallery.jar:?]
    at com.dropbox.core.v2.DbxRawClientV2$1.execute(DbxRawClientV2.java:106) ~[dropgallery.jar:?]
    at com.dropbox.core.v2.DbxRawClientV2.executeRetriable(DbxRawClientV2.java:251) ~[dropgallery.jar:?]
    at com.dropbox.core.v2.DbxRawClientV2.rpcStyle(DbxRawClientV2.java:96) ~[dropgallery.jar:?]
    at com.dropbox.core.v2.files.DbxUserFilesRequests.listFolder(DbxUserFilesRequests.java:629) ~[dropgallery.jar:?]
    at com.dropbox.core.v2.files.DbxUserFilesRequests.listFolder(DbxUserFilesRequests.java:656) ~[dropgallery.jar:?]

Retrieved Image contains no metadata for PNG files

I am making a request for image files with metadata as follows:

dbxClient.files() .listFolderBuilder(path) .withIncludeMediaInfo(true) .start();

However, in the response that comes back, FileMetadata.getMediaInfo() = null for half of my images.
Any reason why this is happening, or what am I doing wrong?

Use JSR 305 Nullable/Nonnull annotations?

Such annotations can help immensely when programming with the API, as it tells the API user what to expect.

Two examples from DbxClient:

  • .startGetFile() can have null as its second argument; it will also never return null; therefore:
@Nonnull
DbxClient.Downloader startGetFile(String path, @Nullable String rev)
  • .getMetadata() can return null:
@Nullable
DbxEntry getMetadata(String path)

Sign out

Hi all, could you tell how to sign out from my app on Android?

No way to get_metadata via fileId or folderId

Is there any way to get_metadata using fileId or folderId? In my case, we need to lookup metadata via a consistent id. File path can be changed.

Or, is there any way that I can lookup file path using fileId?

Thanks,
Lesong

Exception because of missing ProGuard rule: Couldn't find resource "trusted-certs.raw"

I use the SDK in an Android app and after running ProGuard, the app crashed with the exception:

Caused by: java.lang.AssertionError: Couldn't find resource "trusted-certs.raw"
    at com.dropbox.core.a.b.a(Unknown Source)
    at com.dropbox.core.a.b.<clinit>(Unknown Source)
    at com.dropbox.core.a.c.a(Unknown Source)
    ....

This exception is thrown in SSLConfig. I assume because the package names are obfuscated.

I was able to fix this by adding the following ProGuard rule. There might be a better, not so broad option, but I did not want to dig deeper here.

-keeppackagenames com.dropbox.core.http

It might be useful to include this info in the ProGuard section of the README.md.

Open Authentication page in Browser

Hello,

I am using drop box SDK and it is working fine but the problem only that when I launch authentication activity it is pass to the browser and open in full screen If it is possible to open in web view than I can control the UI part.

Thanks in advance

No method to get the file downloading/uploading progress

Hi,
I'm trying to integrate the v2 dropbox sdk into my android app.
I'm working on downloading files, but I cannot find anything in the API which notifies me regarding the downloading progress (as there was before on v1.6, i.e. the ProgressListener).
Am I missing something or have you removed this important feature?

Thanks!

Make android, google app engine etc OSGi Import-Package statements have resolution optional

In the MANIFEST.MF there is an Import-Package statement for OSGi containers. The statement correctly lists all the required packages, but some are specific to the environment the application is running in and so should be optional. Otherwise, as in our case, even when you're not running in Android or Google App Engine, you still need those libraries available in the OSGi container!

Current version:

Import-Package: android.app,android.content,android.content.pm,android
 .net,android.os,android.util,com.fasterxml.jackson.core;version="[2.7
 ,3)",com.google.appengine.api.urlfetch,com.squareup.okhttp,javax.net.
 ssl,javax.security.auth.x500,javax.servlet.http,okhttp3,okio

Should be:

Import-Package: android.app;resolution:=optional,android.content;resolution:=optional,android.content.pm;resolution:=optional,android
 .net;resolution:=optional,android.os;resolution:=optional,android.util;resolution:=optional,com.fasterxml.jackson.core;version="[2.7
 ,3)",com.google.appengine.api.urlfetch;resolution:=optional,com.squareup.okhttp,javax.net.
 ssl,javax.security.auth.x500,javax.servlet.http,okhttp3,okio

DeletedMetadata.getPathDisplay() - lower case

This method seems to incorrectly returning .getPathLower() value. If the path display is not available, possibly DeletedMetadata should not support the method (no method or throw exception... maybe null?).

listfolder returning not last revision

Hello,
playing with Java V2 API (version 2.0.1) I noticed a strange behavior: listFolder seems to return back a previous "snapshot" of the folder content.

I created in one of the folder under my app the following files: sample.xml, test2,xml, test3,xml and test4,xml.

After some hours I deleted the file sample.xml, created the file test1.xml and overwrote the other remaning 3.

If a try to do a listfolder after the update I still get back the file sample.xml, test2.xml, test3,xml and test4.xml (even with the old content).

The same does not happen using Python API.
Am I doing something wrong with API?

Thank you
Simone

SDK is very Large (~8MB) and has a high method count

This library needs to be shrink down. Currently it has 19829 method count which is way to large.

Below is the break down of the method count taken from http://www.methodscount.com/?lib=com.dropbox.core%3Adropbox-core-sdk%3A2.0.1

Library name: com.dropbox.core:dropbox-core-sdk:2.0.1
Total count: 19829

Methods count: 9087
Dependencies: 3
JAR Size (KB): 1897
DEX size (KB): 1214
Dependencies methods count: 10742
Dependencies JAR size (KB): 1503
Dependencies DEX size (KB): 1346

DbxClient.getAccountInfo throws exception with negative quota_info.shared value

Sometimes when I call DbxClient.getAccountInfo(), the DropBox server returns a negative value for "quota_info.shared". When this happens, the method throws an exception:
com.dropbox.core.DbxException$BadResponse: error in response JSON: 1.250: "quota_info"."shared": expecting a non-negative number, got: -1297260
at com.dropbox.core.DbxRequestUtil.readJsonFromResponse(DbxRequestUtil.java:222)
at com.dropbox.core.DbxClient$4.handle(DbxClient.java:284)
at com.dropbox.core.DbxClient$4.handle(DbxClient.java:279)
at com.dropbox.core.DbxRequestUtil.doGet(DbxRequestUtil.java:242)
at com.dropbox.core.DbxClient.doGet(DbxClient.java:1942)
at com.dropbox.core.DbxClient.getAccountInfo(DbxClient.java:279)

I am using dropbox core sdk 1.7.7, but the latest seems to have the same problem with assuming that the "shared" value must be unsigned.

java.net.SocketTimeoutException when file is around 100 MB

Eror is:
W/System.err: com.dropbox.core.DbxException$NetworkIO: java.net.SocketTimeoutException: timeout
W/System.err: at com.dropbox.core.DbxUploader.finish(DbxUploader.java:50)

Is it possible to provide a method to set connection time-out?

Muting deletions and folder creation

First off: I like the new SDK. It's a huge improvement over the old one, looking at the API.

When uploading a file it's possible to mute notifications using UploadBuilder.mute(). Are there any plans to make this functionality also available when deleting a file/folder and when creating a folder?

com.dropbox.core.json.JsonReadException when renaming a folder

It looks like DropBox sends an unexpected "hash" field in its JSON response when renaming a folder (DbxClient.move).

An exception is thrown by the following code in DbxEntry.read(JsonParser parser, Collector<DbxEntry, ? extends C> collector)

 case FM_hash:
 if (collector == null) throw new JsonReadException("not expecting \"hash\" field, since we didn't ask for children", parser.getCurrentLocation());
hash = JsonReader.StringReader.readField(parser, fieldName, hash); break;

Shouldn't that test be removed ?


2013-08-23 12:42:24,lucclaes0018,[STACK],(52),com.dropbox.core.DbxException$BadResponse: error in response JSON: 1.11: "hash": not expecting "hash" field, since we didn't ask for children
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.dropbox.core.DbxRequestUtil.readJsonFromResponse(DbxRequestUtil.java:221)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.dropbox.core.DbxClient$18.handle(DbxClient.java:1767)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.dropbox.core.DbxClient$18.handle(DbxClient.java:1761)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.dropbox.core.DbxRequestUtil.finishResponse(DbxRequestUtil.java:300)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.dropbox.core.DbxRequestUtil.doPostNoAuth(DbxRequestUtil.java:293)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.dropbox.core.DbxRequestUtil.doPost(DbxRequestUtil.java:286)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.dropbox.core.DbxClient.doPost(DbxClient.java:1785)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.dropbox.core.DbxClient.move(DbxClient.java:1760)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.contactoffice.documents.dropbox.DropBoxFileOrDirectory.setName(DropBoxFileOrDirectory.java:89)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.contactoffice.gwt.DocumentsHandler.renameDirectory(DocumentsHandler.java:432)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.contactoffice.gwt.GWTServlet.renameDirectory(GWTServlet.java:274)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at java.lang.reflect.Method.invoke(Method.java:601)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.contactoffice.gwt.GWTServlet.processCall(GWTServlet.java:163)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1336)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:82)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:243)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:536)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.server.Server.handle(Server.java:365)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:937)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:998)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at java.lang.Thread.run(Thread.java:722)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),Caused by: com.dropbox.core.json.JsonReadException: 1.11: "hash": not expecting "hash" field, since we didn't ask for children
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.dropbox.core.DbxEntry.read(DbxEntry.java:433)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.dropbox.core.DbxEntry$1.read(DbxEntry.java:286)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.dropbox.core.DbxEntry$1.read(DbxEntry.java:282)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.dropbox.core.json.JsonReader.readFully(JsonReader.java:349)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.dropbox.core.json.JsonReader.readFully(JsonReader.java:238)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  at com.dropbox.core.DbxRequestUtil.readJsonFromResponse(DbxRequestUtil.java:218)
2013-08-23 12:42:24,lucclaes0018,[STACK],(52),  ... 50 more

Error when using DbxRequestConfig

When using public DbxRequestConfig(String clientIdentifier) , I get the following error at run time:

Exception in thread "Thread-1" java.lang.NoSuchMethodError: com.dropbox.core.DbxRequestConfig.(Ljava/lang/String;)V

However, using the deprecated version works fine:
public DbxRequestConfig(String clientIdentifier, /@nullable/ String userLocale)

DbxRequestConfig requestConfig = new DbxRequestConfig("MyApp/1.0"); does not work
DbxRequestConfig requestConfig = new DbxRequestConfig("MyApp/1.0", "en-US");works

Usage in OSGi Subsystems: Require-Capability

Hello,

the dropbox sdk java currently uses the "maven-bundle-plugin", which automatically generates an OSGi-Subsystem compatible "Require-Capability" that expresses the base JRE requirement of the bundle: Require-Capability: "osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.6))".

When using an OSGi container, e.g., equinox >= v3.8.2 + aries.subsystem, and packaging the dropbox sdk java bundle into a subsystem on a more recent JRE, the subsystem cannot start because of the (outdated?) required JRE capability.

Hence, to make the bundle usable in an OSGi subsystem either the required JRE version will be updated or through an additional BND instruction in the "maven-bundle-plugin", which prevents the plugin to generate the "Require-Capability".
...
true

<_noee>true</_noee>

...

If you like, I can as well provide a pull request for that.

Best Regards,
Daniel

How do you establish an HTTPS connection with Dropbox on Java JDK 1.6?

I'm writing an API that will provide Dropbox services using the Java SDK for API v2. However, I'm running in to some issues when it comes to establishing an HTTPS connection with the SSL configuration provided by Dropbox.

Attempted Step 1: When I use the default configuration using the StandardHttpRequestor, I got a ClassCastException from the following:

private HttpsURLConnection prepRequest(String url, Iterable<Header> headers) throws IOException
{
    URL urlObject = new URL(url);
    HttpsURLConnection conn = (HttpsURLConnection) urlObject.openConnection(this.proxy);

with the following out exception

java.lang.ClassCastException:            com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl 
cannot be cast to javax.net.ssl.HttpsURLConnection  at 
com.dropbox.core.http.StandardHttpRequestor.prepRequest(StandardHttpRequestor.java:150)  at 
com.dropbox.core.http.StandardHttpRequestor.startPost(StandardHttpRequestor.java:75)  at 
com.dropbox.core.http.StandardHttpRequestor.startPost(StandardHttpRequestor.java:23)  at 

Attempted Step 2: To resolve the ClassCastException I created a subclass to StandardHttpRequestor where I made the following change:

    URL urlObject = new URL(null, url, new sun.net.www.protocol.https.Handler());

And I received the following DbxException$NetworkIO from:

public static HttpRequestor.Response startPostRaw(DbxRequestConfig requestConfig, String host, String path, byte[] body, /@Nullable/ArrayList headers) throws DbxException.NetworkIO {     String uri = buildUri(host, path);
headers = addUserAgentHeader(headers, requestConfig);
headers.add(new HttpRequestor.Header("Content-Length", Integer.toString(body.length)));

try {
    HttpRequestor.Uploader uploader = requestConfig.httpRequestor.startPost(uri, headers);
    try {
        uploader.body.write(body);
        return uploader.finish();
    }
    finally {
        uploader.close();
    }
}
catch (IOException ex) {
    throw new DbxException.NetworkIO(ex);
}

with the following out exception

com.dropbox.core.DbxException$NetworkIO: 
javax.net.ssl.SSLException: java.lang.RuntimeException: Could not generate DH keypair  at 
com.dropbox.core.DbxRequestUtil.startPostRaw(DbxRequestUtil.java:192)  at 
com.dropbox.core.DbxRequestUtil.startPostNoAuth(DbxRequestUtil.java:164)  at 
com.dropbox.core.DbxRequestUtil.doPostNoAuth(DbxRequestUtil.java:326)  at 
com.dropbox.core.DbxWebAuthHelper.finish(DbxWebAuthHelper.java:43)  at 
com.dropbox.core.DbxWebAuthNoRedirect.finish(DbxWebAuthNoRedirect.java:86)  at 

Any plans to make a separate, Java 7+ (or even 8+) API?

From my understanding, the only reason that 6 is required is because of Android.

Does Dropbox have any plans to offer a more modern version of the API? Especially since it becomes harder and harder to lay one's hand on a Java 6 SDK implementation nowadays...

Sharing files folders ..

Hi hi guys,
I have used the SDK v1 to upload and share files and folders and it was quite easy.
I am wondering if it is the same for the version of sdk 2 .. knowing that it is still in beta4 .
I have tested that code :

/** **/
DbxRequestConfig config = new DbxRequestConfig("dropbox/java-tutorial", "en_US");
DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);

ListFoldersResult shr_result = client.sharing.listFolders();
ArrayList shr_list = shr_result.entries;
for(SharedFolderMetadata shr_data : shr_list){
System.out.println("Share Folder : "+shr_data.name);
}
/** **/
and I have getting this error:
Exception in thread "main" com.dropbox.core.DbxException$BadRequest: Error in call to API function "sharing/list_folders": Your API app is an "App Folder" app. It is not allowed to access this API function.

/** **/
Please can you share some samples about sharing data to public or to some restricted list of members.
Thanks in advance

upload-file example error

Relevent file

On line 123, method uploadSessionAppendV2 is undefined for type DbxUserFilesRequests. The possible fix, uploadSessionAppend, does not take argument of type UploadSessionCursor.

I encountered this error when importing this file into a Maven project I created in Eclipse.

sdk-version version checking regex mismatch

Hi. The regex in DbxSdkVersion.java is looking for strings of the form 1.8-a . Do you mean to enforce the trailing hyphen and subversion ? I'm getting LoaderErrors since the text file adk-version.txt only contains version strings like 1.8

Sharing Files SDK v2

I'm using the SDK v2 and trying to share the folders. I've the "Full Dropbox" in the App's settings.
I tried the houssemzaier's cod but I needed to do some fixes...
ListFoldersResult shr_result = client.sharing().listFolders();
ArrayList shr_list = shr_result.getEntries();
In the second line I'm not able to get the result.getEntries() to the ArrayList.
Thanks in advance.

mvn install fails with checker framework error

I am trying to run the examples. I ran mvn install on project dir and ran into this error. mvn checkers:check produces the same error too. Any idea?

[INFO] Executed tasks
[INFO] 
[INFO] --- checkers-maven-plugin:1.7.2:check (default) @ dropbox-core-sdk ---
[INFO] Running Checker Framework version: 1.7.2
[INFO] Running processor(s): checkers.nullness.NullnessChecker
[INFO] -------------------------------------------------------------
[WARNING] CHECKER FRAMEWORK ERROR: 
[INFO] -------------------------------------------------------------
[ERROR] /Users/arul/github/dropbox/dropbox-sdk-java/src/com/dropbox/core/DbxEntry.java:[284,34] @Initialized @Nullable File read(@Initialized @NonNull <anonymous com.dropbox.core.DbxEntry$File$2> this, @Initialized @NonNull JsonParser p0) throws @Initialized @NonNull IOException@Initialized @NonNull JsonReadException in <anonymous com.dropbox.core.DbxEntry$File$2> cannot override @Initialized @NonNull File read(@Initialized @NonNull JsonReader<@Initialized @NonNull File> this, @Initialized @NonNull JsonParser p0) throws @Initialized @NonNull IOException@Initialized @NonNull JsonReadException in com.dropbox.core.json.JsonReader; attempting to use an incompatible return type
  found   : @Initialized @Nullable File
  required: @Initialized @NonNull File
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 35.801s
[INFO] Finished at: Wed Feb 05 16:57:47 HST 2014
[INFO] Final Memory: 24M/318M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal types.checkers:checkers-maven-plugin:1.7.2:check (default) on project dropbox-core-sdk: Errors found by the processor(s): Errors found by the processor(s):
[ERROR] /Users/arul/github/dropbox/dropbox-sdk-java/src/com/dropbox/core/DbxEntry.java:[284,34] @Initialized @Nullable File read(@Initialized @NonNull <anonymous com.dropbox.core.DbxEntry$File$2> this, @Initialized @NonNull JsonParser p0) throws @Initialized @NonNull IOException@Initialized @NonNull JsonReadException in <anonymous com.dropbox.core.DbxEntry$File$2> cannot override @Initialized @NonNull File read(@Initialized @NonNull JsonReader<@Initialized @NonNull File> this, @Initialized @NonNull JsonParser p0) throws @Initialized @NonNull IOException@Initialized @NonNull JsonReadException in com.dropbox.core.json.JsonReader; attempting to use an incompatible return type
[ERROR] found   : @Initialized @Nullable File
[ERROR] required: @Initialized @NonNull File
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Android SDK repository

Hey guys,

sorry to post it here but where is the Android's repository? I would like to include the parameter include_deleted as a option for method metadata(String path, int fileLimit, String hash, boolean list, String rev) and then create a pull request but I can't find it anywhere. Where can I do that?

Thanks!

ListFolderBuilder's start() throws empty ServerException

I'm getting error reports from a user. My code (using the latest version of the SDK, 2.0.5):

final ListFolderBuilder folderBuilder = mDbxClient.files()
        .listFolderBuilder("")
        .withRecursive(true);
return folderBuilder.start();

The error report:

com.dropbox.core.ServerException: 
       at [..]
Caused by com.dropbox.core.ServerException
       at com.dropbox.core.DbxRequestUtil.unexpectedStatus(DbxRequestUtil.java:296)
       at com.dropbox.core.v2.DbxRawClientV2$1.execute(DbxRawClientV2.java:107)
       at com.dropbox.core.v2.DbxRawClientV2.executeRetriable(DbxRawClientV2.java:252)
       at com.dropbox.core.v2.DbxRawClientV2.rpcStyle(DbxRawClientV2.java:97)
       at com.dropbox.core.v2.files.DbxUserFilesRequests.listFolder(DbxUserFilesRequests.java:629)
       at com.dropbox.core.v2.files.ListFolderBuilder.start(ListFolderBuilder.java:109)
       [..]

It looks like the message for the ServerException is empty. Any idea what could happen here? The user reported that even after reinstalling the issue continues to occur. The user verified that the app is still linked. This happens on a HTC One running Android 5.0.2.

If it helps I can send the request ID (the one DbxException holds), but I do not want to post it here in public.

Upload Hangs with wrong path

Hi guys,

I was playing around with the sdk to upload a simple txt file to my dropbox app folder. As you see i'm using scala.
The upload was always blocking the thread until I realised that i needed to add a leading / to the filename. As a developer I expect an Exception to be thrown in this case.

val fileName = "test.txt"
val inputFile = new java.io.File("/tmp/"+fileName);                  

if(!inputFile.exists){
    throw new FileNotFoundException("file to upload not found")
}

val inputStream = new FileInputStream(inputFile);
val dropBoxConfig = new DbxRequestConfig( "App/1.0", Locale.getDefault().toString())
val client = new DbxClient(dropBoxConfig, authToken)

//this works now, did not without the leading /
val uploadedFile = client.uploadFile("/"+fileName, DbxWriteMode.add(), inputFile.length(), inputStream); 

inputStream.close()
inputFile.delete()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.