First create a DbxClient (shown in the examples), then upload:
/**
* Upload a file to your Dropbox
* @param srcFilename path to the source file to be uploaded
* e.g. /tmp/upload.txt
* @param destFilename path to the destination.
* Must start with '/' and must NOT end with'/'
* e.g. /target_dir/upload.txt
* @param dbxClient a DbxClient created using an auth-token for your Dropbox app
* @throws IOException
*/
public void upload (String srcFilename, String destFilename, DbxClient dbxClient) throws IOException {
File uploadFile = new File (srcFilename);
FileInputStream uploadFIS;
try {
uploadFIS = new FileInputStream(uploadFile);
}
catch (FileNotFoundException e1) {
e1.printStackTrace();
System.err.println("Error in upload(): problem opening " + srcFilename);
return;
}
String targetPath = destFilename;
try {
dbxClient.uploadFile(targetPath, DbxWriteMode.add(), uploadFile.length(), uploadFIS);
}
catch (DbxException e) {
e.printStackTrace();
uploadFIS.close();
System.err.println("Error in upload(): " + e.getMessage());
System.exit(1);
return;
}
}