Ejemplo n.º 1
0
  public boolean push() {
    if (!isLinked()) return false;

    FileInputStream inputStream = null;
    try {
      app.getGui().setStatus("Uploading...");
      File[] files = new File(NoteManager.defaultPath).listFiles();
      for (int i = 0; i < files.length; i++) {
        inputStream = new FileInputStream(files[i]);
        mDBApi.putFileOverwrite(
            "/".concat(files[i].getName()), inputStream, files[i].length(), null);
        app.getGui().setStatus("Uploaded ".concat(files[i].getName()));
        inputStream.close();
      }
      return true;
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      app.getGui().setStatus("Files not found.");
    } catch (DropboxException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      app.getGui().setStatus("Couldn't connect to server.");
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      app.getGui().setStatus("IO errors.");
    }
    return false;
  }