Dropbox Android CoreApi trying to upload a file and get "Source not found'

ぃ、小莉子 提交于 2019-12-12 05:03:46

问题


Im trying to upload file to the dropbox using Android core Api as following: as described in Link

private DropboxAPI<AndroidAuthSession> mDBApi;

// And later in some initialization function:
AppKeyPair appKeys = new AppKeyPair(APP_KEY, APP_SECRET);
AndroidAuthSession session = new AndroidAuthSession(appKeys, ACCESS_TYPE);
mDBApi = new DropboxAPI<AndroidAuthSession>(session);

 // MyActivity below should be your activity class name
mDBApi.getSession().startOAuth2Authentication(MyActivity.this);

protected void onResume() {
    super.onResume();

    if (mDBApi.getSession().authenticationSuccessful()) {
        try {
            // Required to complete auth, sets the access token on the session
            mDBApi.getSession().finishAuthentication();

            String accessToken = mDBApi.getSession().getOAuth2AccessToken();
        } catch (IllegalStateException e) {
            Log.i("DbAuthLog", "Error authenticating", e);
        }
    }
}

 File path = Environment.getExternalStoragePublicDirectory(
                                Environment.DIRECTORY_MOVIES);
                        File file = new File(path, "/" + "fname");

                        FileInputStream inputStream = null;
                        String text = "Hello world";
                        try {
                          BufferedWriter output = new BufferedWriter(new FileWriter(file));
                          output.write(text);
                          output.close();
                          inputStream = new FileInputStream(file);
                        } catch ( IOException e ) {
                           e.printStackTrace();
                        }
                        try {
                                    com.dropbox.client2.DropboxAPI.Entry response = mDBApi.putFile("/magnum-opus.txt", inputStream, file.length(), null, null);
                              } catch (DropboxException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                              }

And I get Source not found. After the line:

com.dropbox.client2.DropboxAPI.Entry response = mDBApi.putFile("/magnum-opus.txt", inputStream, file.length(), null, null);

And it Does not continue to the next line

来源:https://stackoverflow.com/questions/24954249/dropbox-android-coreapi-trying-to-upload-a-file-and-get-source-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!