Tabnine Logo
DbxClientV2
Code IndexAdd Tabnine to your IDE (free)

How to use
DbxClientV2
in
com.dropbox.core.v2

Best Java code snippets using com.dropbox.core.v2.DbxClientV2 (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
List l =
  • Codota Iconnew ArrayList()
  • Codota Iconnew LinkedList()
  • Smart code suggestions by Tabnine
}
origin: org.apache.camel/camel-dropbox

/**
 * Obtain a new instance of DbxClient and store it in configuration.
 */
public void createClient() {
  DbxRequestConfig config = new DbxRequestConfig(clientIdentifier, Locale.getDefault().toString());
  this.client = new DbxClientV2(config, accessToken);
}
origin: sebbrudzinski/Open-LaTeX-Studio

private static File downloadRemoteFile(String revision, String remotePath, String localPath) {
  DbxClientV2 client = getDbxClient();
  
  FileOutputStream outputStream = null;
  File outputFile = new File(localPath);
  
  try {
    outputStream = new FileOutputStream(outputFile);
    client.files().download(remotePath, revision).download(outputStream);
  } catch (DbxException | IOException ex) {
    Exceptions.printStackTrace(ex);
  } finally {
    IOUtils.closeQuietly(outputStream);
  }
  
  return outputFile;
}

origin: io.syndesis.connector/connector-dropbox

private void verifyCredentials(ResultBuilder builder, Map<String, Object> parameters) {
  String token = (String) parameters.get("accessToken");
  String clientId = (String) parameters.get("clientIdentifier");
  try {
    // Create Dropbox client
    DbxRequestConfig config = new DbxRequestConfig(clientId, Locale.getDefault().toString());
    DbxClientV2 client = new DbxClientV2(config, token);
    client.users().getCurrentAccount();
  } catch (DbxException e) {
    builder.error(ResultErrorBuilder
        .withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION,
            "Invalid client identifier and/or access token")
        .parameterKey("accessToken").parameterKey("clientIdentifier").build());
  }
}
origin: quebic-source/microservices-sample-project

private FileMetadata dropBoxSave(String uploadPath, InputStream inputStream)throws Exception{
  DbxRequestConfig config = new DbxRequestConfig(APP_IDENTIFIER);
  DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);
  return client.files().uploadBuilder(uploadPath).uploadAndFinish(inputStream);
}
origin: sebbrudzinski/Open-LaTeX-Studio

private void displayCloudStatus() {
  String message = "Working locally.";
  String displayName;
  // Check Dropbox connection
  DbxClientV2 client = DbxUtil.getDbxClient();
  if (client != null) {  
    try {
      displayName = client.users().getCurrentAccount().getName().getDisplayName();
      message = "Connected to Dropbox account as " + displayName + ".";
      Cloud.getInstance().setStatus(Cloud.Status.DBX_CONNECTED, " (" + displayName + ")");
    } catch (DbxException ex) {
      // simply stay working locally.
      Cloud.getInstance().setStatus(Cloud.Status.DISCONNECTED);
    }
  }
  
  LOGGER.log(message);
}
 
origin: dsolonenko/financisto

public void deAuth() {
  MyPreferences.removeDropboxKeys(context);
  if (dropboxClient != null) {
    try {
      dropboxClient.auth().tokenRevoke();
    } catch (DbxException e) {
      Log.e("Financisto", "Unable to unlink Dropbox", e);
    }
  }
}
origin: quebic-source/microservices-sample-project

  @Override
  public void writeTo(OutputStream outputStream) {
    try {
      String fileStr = SEPARATOR + imageDir + SEPARATOR + id + SEPARATOR + fileName;
      DbxRequestConfig config = new DbxRequestConfig(APP_IDENTIFIER);
      DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);
      client.files().download(fileStr).download(outputStream);
    } catch (Exception e) {
      logger.error(e.getMessage());
      throw new ResourceNotFoundException("Image Not Found : " + id + "/" + fileName);
    }
  }
};
origin: sebbrudzinski/Open-LaTeX-Studio

String additional = "";
if(client != null) {
  additional = " (" + client.users().getCurrentAccount().getName().getDisplayName() + ")";
origin: sebbrudzinski/Open-LaTeX-Studio

client.auth().tokenRevoke();
origin: adrian/upm-android

@Override
protected Integer doInBackground(Void... params) {
  try {
    ListFolderResult filderContents =
        DropboxClientFactory.getClient().files().listFolder("");
    dropBoxEntries = filderContents.getEntries();
    return 0;
  } catch (InvalidAccessTokenException e) {
    Log.e(TAG, "InvalidAccessTokenException downloading database", e);
    return ERROR_DROPBOX_INVALID_TOKEN;
  } catch (DbxException e) {
    Log.e(TAG, "DbxException downloading database", e);
    return ERROR_DROPBOX;
  }
}
origin: com.dropbox.core/dropbox-core-sdk

/**
 * Returns a new {@link DbxClientV2} that performs requests against Dropbox API
 * user endpoints relative to a namespace without including the namespace as
 * part of the path variable for every request.
 * (<a href="https://www.dropbox.com/developers/reference/namespace-guide#pathrootmodes">https://www.dropbox.com/developers/reference/namespace-guide#pathrootmodes</a>).
 *
 * <p> This method performs no validation of the namespace ID. </p>
 *
 * @param pathRoot  the path root for this client, never {@code null}.
 *
 * @return Dropbox client that issues requests with Dropbox-API-Path-Root header.
 *
 * @throws IllegalArgumentException  If {@code pathRoot} is {@code null}
 */
public DbxClientV2 withPathRoot(PathRoot pathRoot) {
  if (pathRoot == null) {
    throw new IllegalArgumentException("'pathRoot' should not be null");
  }
  return new DbxClientV2(_client.withPathRoot(pathRoot));
}
origin: org.apache.camel/camel-dropbox

private void verifyCredentials(ResultBuilder builder, Map<String, Object> parameters) {
  String token = (String) parameters.get("accessToken");
  String clientId = (String) parameters.get("clientIdentifier");
  try {
    // Create Dropbox client
    DbxRequestConfig config = new DbxRequestConfig(clientId, Locale.getDefault().toString());
    DbxClientV2 client = new DbxClientV2(config, token);
    client.users().getCurrentAccount();
    client = null;
  } catch (Exception e) {
    builder.error(ResultErrorBuilder
        .withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION,
            "Invalid client identifier and/or access token")
        .parameterKey("accessToken").parameterKey("clientIdentifier").build());
  }
}
origin: org.apache.camel/camel-dropbox

private FileMetadata putSingleFile(File inputFile, String dropboxPath, DropboxUploadMode mode) throws Exception {
  FileInputStream inputStream = new FileInputStream(inputFile);
  FileMetadata uploadedFile;
  try {
    WriteMode uploadMode;
    if (mode == DropboxUploadMode.force) {
      uploadMode = WriteMode.OVERWRITE;
    } else {
      uploadMode = WriteMode.ADD;
    }
    uploadedFile = client.files().uploadBuilder(dropboxPath).withMode(uploadMode).uploadAndFinish(inputStream, inputFile.length());
    return uploadedFile;
  } finally {
    IOHelper.close(inputStream);
  }
}
origin: sebbrudzinski/Open-LaTeX-Studio

public static DbxClientV2 getDbxClient() {
  String accessToken = (String) ApplicationSettings.Setting.DROPBOX_TOKEN.getValue();
  if (accessToken == null) {
    JOptionPane.showMessageDialog(null, 
      "The authentication token has not been set.\n"
          + "Please connect the application to your Dropbox account first!", 
      "Dropbox authentication token not found", JOptionPane.ERROR_MESSAGE
    );
    return null;
  }
  return new DbxClientV2(getDbxConfig(), accessToken); 
}

origin: org.apache.camel/camel-dropbox

private Map<String, Object> downloadFilesInFolder(String path) throws DropboxException {
  try {
    ListFolderResult folderResult = client.files().listFolder(path.equals("/") ? "" : path);
    Map<String, Object> returnMap = new LinkedHashMap<>();
    for (Metadata entry : folderResult.getEntries()) {
      returnMap.put(entry.getPathDisplay(), downloadSingleFile(entry.getPathDisplay()).getValue());
    }
    return returnMap;
  } catch (ListFolderErrorException e) {
    try {
      DbxDownloader<FileMetadata> listing = client.files().download(path);
      if (listing == null) {
        return Collections.emptyMap();
      } else {
        LOG.debug("downloading a single file...");
        Map.Entry<String, Object> entry = downloadSingleFile(path);
        return Collections.singletonMap(entry.getKey(), entry.getValue());
      }
    } catch (DbxException dbxException) {
      throw new DropboxException(dbxException);
    }
  } catch (DbxException e) {
    throw new DropboxException(e);
  }
}
origin: quebic-source/microservices-sample-project

@Override
public ResponseEntity<StreamingResponseBody> readFile(String fileLocation, String imageDir, String id,
    String fileName) {
  
  StreamingResponseBody streamingResponseBody = new StreamingResponseBody() {
    @Override
    public void writeTo(OutputStream outputStream) {
      try {
        String fileStr = SEPARATOR + imageDir + SEPARATOR + id + SEPARATOR + fileName;
        DbxRequestConfig config = new DbxRequestConfig(APP_IDENTIFIER);
        DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);
        client.files().download(fileStr).download(outputStream);
      } catch (Exception e) {
        logger.error(e.getMessage());
        throw new ResourceNotFoundException("Image Not Found : " + id + "/" + fileName);
      }
    }
  };
  HttpHeaders headers = new HttpHeaders();
  headers.add(HttpHeaders.CONTENT_TYPE, "image/*");
  return new ResponseEntity<StreamingResponseBody>(streamingResponseBody, headers, HttpStatus.OK);
}
origin: adrian/upm-android

outputStream = new FileOutputStream(file);
DropboxClientFactory.getClient()
    .files()
    .download("/" + fileName[0])
    .download(outputStream);
origin: com.dropbox.core/dropbox-core-sdk

/**
 * Returns a {@link DbxClientV2} that performs requests against Dropbox API
 * user endpoints as the given team member.
 *
 * <p> This method performs no validation of the team member ID. </p>
 *
 * @param memberId  Team member ID of member in this client's team, never
 *     {@code null}.
 *
 * @return Dropbox client that issues requests to user endpoints as the
 *     given team member
 *
 * @throws IllegalArgumentException  If {@code memberId} is {@code null}
 */
public DbxClientV2 asMember(String memberId) {
  if (memberId == null) {
    throw new IllegalArgumentException("'memberId' should not be null");
  }
  DbxRawClientV2 asMemberClient = new DbxTeamRawClientV2(
    _client.getRequestConfig(),
    _client.getHost(),
    accessToken,
    _client.getUserId(),
    memberId,
    null,
    null
  );
  return new DbxClientV2(asMemberClient);
}
origin: org.apache.camel/camel-dropbox

/**
 * Rename a remote path with the new path location.
 *
 * @param remotePath the existing remote path to be renamed
 * @param newRemotePath the new remote path substituting the old one
 * @return a result object with the result of the move operation.
 * @throws DropboxException
 */
public DropboxMoveResult move(String remotePath, String newRemotePath) throws DropboxException {
  try {
    client.files().moveV2(remotePath, newRemotePath);
    return new DropboxMoveResult(remotePath, newRemotePath);
  } catch (DbxException e) {
    throw new DropboxException(remotePath + " does not exist or cannot obtain metadata", e);
  }
}
origin: com.dropbox.core/dropbox-core-sdk

/**
 * Returns a {@link DbxClientV2} that performs requests against Dropbox API
 * user endpoints as the given team admin.
 *
 * <p> This method performs no validation of the team admin ID. </p>
 *
 * @param adminId  Team member ID of the admin in client's team, never
 *     {@code null}.
 *
 * @return Dropbox client that issues requests to user endpoints as the
 *     given team Admin.
 *
 * @throws IllegalArgumentException  If {@code adminId} is {@code null}
 */
public DbxClientV2 asAdmin(String adminId) {
  if (adminId == null) {
    throw new IllegalArgumentException("'adminId' should not be null");
  }
  DbxRawClientV2 asAdminClient = new DbxTeamRawClientV2(
    _client.getRequestConfig(),
    _client.getHost(),
    accessToken,
    _client.getUserId(),
    null,
    adminId,
    null
  );
  return new DbxClientV2(asAdminClient);
}
com.dropbox.core.v2DbxClientV2

Javadoc

Use this class to make remote calls to the Dropbox API user endpoints. User endpoints expose actions you can perform as a Dropbox user. You'll need an access token first, normally acquired by directing a Dropbox user through the auth flow using com.dropbox.core.DbxWebAuth.

This class has no mutable state, so it's thread safe as long as you pass in a thread safe HttpRequestor implementation.

Most used methods

  • <init>
    For internal use only. Used by other clients to provide functionality like DbxTeamClientV2.asMember(
  • files
  • users
  • auth

Popular in Java

  • Updating database using SQL prepared statement
  • findViewById (Activity)
  • putExtra (Intent)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Top 17 PhpStorm Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now