当前位置: 首页>>代码示例>>Java>>正文


Java DbxClientV2类代码示例

本文整理汇总了Java中com.dropbox.core.v2.DbxClientV2的典型用法代码示例。如果您正苦于以下问题:Java DbxClientV2类的具体用法?Java DbxClientV2怎么用?Java DbxClientV2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DbxClientV2类属于com.dropbox.core.v2包,在下文中一共展示了DbxClientV2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: syncUploadFile

import com.dropbox.core.v2.DbxClientV2; //导入依赖的package包/类
public Object syncUploadFile(DbxClientV2 mDbxClient, String localUri, String remoteFolder) {
    Log.d(TAG, "localUri: " + localUri);
    File localFile = new File(localUri);
    if (localFile.exists()) {
        // Note - this is not ensuring the name is a valid dropbox file name
        String remoteFileName = localFile.getName();
        try (InputStream inputStream = new FileInputStream(localFile)) {
            return mDbxClient.files().uploadBuilder(remoteFolder + "/" + remoteFileName)
                    .withMode(WriteMode.OVERWRITE).uploadAndFinish(inputStream);
        } catch (Exception e) {
            Log.e(TAG, "stringUploadFile", e);
            return e;
        }
    }
    return null;
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:17,代码来源:DropboxManager.java

示例2: buildSession

import com.dropbox.core.v2.DbxClientV2; //导入依赖的package包/类
private void buildSession() {

        String v2Token = getKeyV2();

        if (v2Token != null)
        {
            dbxClient = new DbxClientV2(requestConfig, v2Token);

            setLoggedIn(true);
            Log.d(TAG, "Creating Dropbox Session with accessToken");
        } else {
            setLoggedIn(false);
            Log.d(TAG, "Creating Dropbox Session without accessToken");
        }

    }
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:17,代码来源:DropboxV2Storage.java

示例3: syncWorldToDropbox

import com.dropbox.core.v2.DbxClientV2; //导入依赖的package包/类
/**
 * Syncs the current World's files to the user's Dropbox account.
 *
 * <p>
 *     If the user has not yet linked a Dropbox account, they will be asked to authenticate
 *     their account.
 * </p>
 *
 * <p>
 *     If an error occurs while syncing files, a message will be displayed.
 * </p>
 */
private void syncWorldToDropbox() {
    if (!(AppPreferences.dropboxAccessTokenExists(this))) {
        Auth.startOAuth2Authentication(getApplicationContext(), DROPBOX_APP_KEY);
        // Since the Authentication Activity interrupts the flow of this method,
        // the actual syncing should occur when the user returns to this Activity after
        // authentication.
        syncWorldToDropboxOnResume = true;
    } else {
        new AlertDialog.Builder(this)
                .setTitle(this.getString(R.string.confirmBackupToDropboxTitle, worldName))
                .setMessage(this.getString(R.string.confirmBackupToDropbox, worldName))
                .setIcon(android.R.drawable.ic_dialog_alert)
                .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int whichButton) {
                    String accessToken = getDropboxAccessToken();
                    DbxClientV2 client = getDropboxClient(accessToken);
                    File worldDirectory = FileRetriever.getWorldDirectory(worldName);
                    new UploadToDropboxTask(client, worldDirectory, ArticleListActivity.this).execute();
                    }})
                .setNegativeButton(android.R.string.no, null).show();
    }
}
 
开发者ID:MarquisLP,项目名称:World-Scribe,代码行数:36,代码来源:ArticleListActivity.java

示例4: append

import com.dropbox.core.v2.DbxClientV2; //导入依赖的package包/类
/** */
private void append(String res, DbxClientV2 client) throws DbxException, IOException {
    File tmp = createTmpFile();

    try (FileOutputStream out = new FileOutputStream(tmp)) {
        client.files().download(dropboxPath).download(out);
    }

    writeResults(res, tmp);

    try (FileInputStream in = new FileInputStream(tmp)) {
        client.files().uploadBuilder(dropboxPath).withMode(WriteMode.OVERWRITE).uploadAndFinish(in);
    }

    if (!tmp.delete())
        System.out.println("Failed to delete " + tmp.getAbsolutePath());

    System.out.println("Uploaded benchmark results to: " + dropboxUrl);
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:ResultsWriter.java

示例5: getFragment

import com.dropbox.core.v2.DbxClientV2; //导入依赖的package包/类
@Override
protected AbstractFilePickerFragment<Metadata> getFragment(@Nullable final String startPath,
                                                           final int mode, final boolean allowMultiple,
                                                           final boolean allowCreateDir, final boolean allowExistingFile,
                                                           final boolean singleClick) {
    DropboxFilePickerFragment fragment = null;

    if (!dropboxHelper.authenticationFailed(this)) {
        DbxClientV2 dropboxClient = dropboxHelper.getClient(this);

        if (dropboxClient != null) {
            fragment = new DropboxFilePickerFragment(dropboxClient);
            fragment.setArgs(startPath, mode, allowMultiple, allowCreateDir, allowExistingFile, singleClick);
        }
    }

    return fragment;
}
 
开发者ID:spacecowboy,项目名称:NoNonsense-FilePicker,代码行数:19,代码来源:DropboxFilePickerActivity.java

示例6: determineDropboxLink

import com.dropbox.core.v2.DbxClientV2; //导入依赖的package包/类
private String determineDropboxLink(DjConfiguration conf) {
    DbxClientV2 client = getDbxClient();
    try {
        String url;

        DbxUserSharingRequests share = client.sharing();

        ListSharedLinksResult result = share.listSharedLinksBuilder().withPath(dboxFilePath).start();
        List<SharedLinkMetadata> links = result.getLinks();
        if(links.size() > 0) {
            url = links.get(0).getUrl();
        } else {
            SharedLinkSettings settings = new SharedLinkSettings(RequestedVisibility.PUBLIC, null, null);
            SharedLinkMetadata metadata = share.createSharedLinkWithSettings(dboxFilePath, settings);
            url = metadata.getUrl();
        }

        return url.replace("?dl=0", "?raw=1");
    } catch (DbxException e) {
        logger.error("Can't create dropbox link", e);
        return null;
    }
}
 
开发者ID:Hyphen-ated,项目名称:DJBot,代码行数:24,代码来源:DjService.java

示例7: deleteRoot

import com.dropbox.core.v2.DbxClientV2; //导入依赖的package包/类
@BeforeSuite
@AfterSuite(alwaysRun=true)
public static void deleteRoot() throws Exception {
    // always use standard HTTP requestor for delete root
    DbxClientV2 client = newClientV2(
        newRequestConfig()
            .withHttpRequestor(newStandardHttpRequestor())
    );
    try {
        client.files().delete(RootContainer.ROOT);
    } catch (DeleteErrorException ex) {
        if (ex.errorValue.isPathLookup() &&
            ex.errorValue.getPathLookupValue().isNotFound()) {
            // ignore
        } else {
            throw ex;
        }
    }
}
 
开发者ID:dropbox,项目名称:dropbox-sdk-java,代码行数:20,代码来源:ITUtil.java

示例8: main

import com.dropbox.core.v2.DbxClientV2; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    // Only display important log messages.
    Logger.getLogger("").setLevel(Level.WARNING);

    if (args.length != 1) {
        System.out.println("");
        System.out.println("Usage: COMMAND <auth-file>");
        System.out.println("");
        System.out.println(" <auth-file>: An \"auth file\" that contains the information necessary to make");
        System.out.println("    an authorized Dropbox API request.  Generate this file using the \"authorize\"");
        System.out.println("    example program.");
        System.out.println("");
        System.exit(1);
        return;
    }

    DbxClientV2 client = createClient(args[0]);

    runTest(client, Main::testBasicSerialization, "testBasicSerialization");
    runTest(client, Main::testEnumeratedSubtypeSerialization, "testEnumeratedSubtypeSerialization");
    runTest(client, Main::testErrorSerialization, "testErrorSerialization");
}
 
开发者ID:dropbox,项目名称:dropbox-sdk-java,代码行数:23,代码来源:Main.java

示例9: getDbxClient

import com.dropbox.core.v2.DbxClientV2; //导入依赖的package包/类
private DbxClientV2 getDbxClient(String accessToken) {
    String userLocale = Locale.getDefault().toString();

    String clientId = String.format("%s/%s",
            BuildConfig.APPLICATION_ID, BuildConfig.VERSION_NAME);

    DbxRequestConfig requestConfig = DbxRequestConfig
            .newBuilder(clientId)
            .withUserLocale(userLocale)
            .build();

    return new DbxClientV2(requestConfig, accessToken);
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:14,代码来源:DropboxClient.java

示例10: readFile

import com.dropbox.core.v2.DbxClientV2; //导入依赖的package包/类
@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);
}
 
开发者ID:quebic-source,项目名称:microservices-sample-project,代码行数:28,代码来源:DropBoxStorageImageUtil.java

示例11: getClient

import com.dropbox.core.v2.DbxClientV2; //导入依赖的package包/类
/**
 * 
 * get connection client
 */
@Override
public DbxClientV2 getClient(){
    
    DbxRequestConfig config = DbxRequestConfig.newBuilder(appId).withAutoRetryEnabled(3).withUserLocaleFrom(Locale.ITALY).build();
    return new DbxClientV2(config, accessToken);
}
 
开发者ID:diakogiannis,项目名称:EasyDropboxFileHandler,代码行数:11,代码来源:DropboxDbxClient.java

示例12: dropboxGetFiles

import com.dropbox.core.v2.DbxClientV2; //导入依赖的package包/类
public static List<String> dropboxGetFiles(String code) {

        DbxRequestConfig config = new DbxRequestConfig("Media Information Service Configuration");
        DbxClientV2 client = new DbxClientV2(config, code);
        ListFolderResult result = null;
        List<String> elements = new LinkedList<String>();


        try {
            result = client.files().listFolderBuilder("/media").withRecursive(true).start();
            while (true) {
                for (Metadata metadata : result.getEntries()) {
                    if (metadata instanceof FileMetadata) {
                        elements.add(metadata.getName());
                    }
                }

                if (!result.getHasMore()) {
                    break;
                }

                result = client.files().listFolderContinue(result.getCursor());
            }

            //System.out.println(elements.toString());
        } catch (DbxException e) {
            e.printStackTrace();
        }


        return elements;


    }
 
开发者ID:LithiumSR,项目名称:media_information_service,代码行数:35,代码来源:DbxAPIOp.java

示例13: getClient

import com.dropbox.core.v2.DbxClientV2; //导入依赖的package包/类
public static DbxClientV2 getClient(String ACCESS_TOKEN) {
    // Create Dropbox client
    DbxRequestConfig requestConfig = DbxRequestConfig.newBuilder("Flashcard Maker")
            .withHttpRequestor(new OkHttp3Requestor(OkHttp3Requestor.defaultOkHttpClient()))
            .build();
    DbxClientV2 client = new DbxClientV2(requestConfig, ACCESS_TOKEN);
    return client;
}
 
开发者ID:AbduazizKayumov,项目名称:Flashcard-Maker-Android,代码行数:9,代码来源:DropboxClientFactory.java

示例14: logChangedFiles

import com.dropbox.core.v2.DbxClientV2; //导入依赖的package包/类
public void logChangedFiles(final String userId) throws Exception {
    final String accessToken = getTokenAndCheckIsTokenExists(userId);
    final DbxClientV2 client = new DbxClientV2(requestConfig, accessToken);
    final String cursor = userTokenRepository.getValue(CURSORS_HASH_KEY, userId);
    final ListFolderResult listFolderContinue = client.files().listFolderContinue(cursor);
    logChangedFilesOfUser(userId, listFolderContinue);
}
 
开发者ID:zeldan,项目名称:dropbox-webhooks-spring-boot-example,代码行数:8,代码来源:DropboxService.java

示例15: finishAuthAndSaveUserDetails

import com.dropbox.core.v2.DbxClientV2; //导入依赖的package包/类
public void finishAuthAndSaveUserDetails(final HttpSession session, final Map<String, String[]> parameterMap) throws Exception {
    final DbxSessionStore csrfTokenStore = new DbxStandardSessionStore(session, dropboxConfigProp.getSessionStore().getKey());
    final DbxAuthFinish authFinish = auth.finishFromRedirect(dropboxConfigProp.getRedirectUri(), csrfTokenStore, parameterMap);
    final String accessToken = authFinish.getAccessToken();
    final DbxClientV2 client = new DbxClientV2(requestConfig, accessToken);
    final String userId = authFinish.getUserId();
    final ListFolderResult listFolderResult = client.files().listFolderBuilder("").withRecursive(true).start();
    saveAccessTokenAndActualCursor(userId, accessToken, listFolderResult);
}
 
开发者ID:zeldan,项目名称:dropbox-webhooks-spring-boot-example,代码行数:10,代码来源:DropboxService.java


注:本文中的com.dropbox.core.v2.DbxClientV2类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。