问题
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