• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DbxDownloader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: start

import com.dropbox.core.DbxDownloader; //导入依赖的package包/类
protected Bell start(Bell bell) {
   return new ThreadBell() {
     public Object run() throws Exception {
       /*Issue #25
 	Modified by: Dhruva Kumar Srinivasa
Comments: Dropbox v2 API returns a DbxDownloader instance. Call download on the DbxDownloader object, passing an output stream as a parameter*/
       DbxDownloader<FileMetadata> downloader = session.client.files().download(
               source().path.toString());
       downloader.download(asOutputStream());
       //End changes for Issue #21
       finish();
       return null;
     } public void fail(Throwable t) {
       finish();
     }
   }.startOn(initialize().and(bell));
 }
 
开发者ID:didclab,项目名称:onedatashare,代码行数:18,代码来源:DbxResource.java


示例2: read

import com.dropbox.core.DbxDownloader; //导入依赖的package包/类
@Override
public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
    try {
        final DownloadBuilder builder = new DbxUserFilesRequests(session.getClient()).downloadBuilder(file.getAbsolute());
        if(status.isAppend()) {
            final HttpRange range = HttpRange.withStatus(status);
            builder.range(range.getStart());
        }
        final DbxDownloader<FileMetadata> downloader = builder.start();
        return downloader.getInputStream();
    }
    catch(DbxException e) {
        throw new DropboxExceptionMappingService().map("Download {0} failed", e, file);
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:16,代码来源:DropboxReadFeature.java


示例3: readFile

import com.dropbox.core.DbxDownloader; //导入依赖的package包/类
/**
 *
 * @param path The path in dropbox there the file exists
 * @return java.io.InputStream with file contents
 * @throws DbxException
 */
@Override
public InputStream readFile(String path)
        throws DbxException {
    DbxDownloader downloader = client.files().downloadBuilder(path).start();
    InputStream in = downloader.getInputStream();
    return in;
}
 
开发者ID:diakogiannis,项目名称:EasyDropboxFileHandler,代码行数:14,代码来源:FileHandler.java


示例4: downloadFile

import com.dropbox.core.DbxDownloader; //导入依赖的package包/类
/**
 * download dropbox file locally
 * @param dboxFilename
 * @return downloaded local temp file
 * @throws IOException
 * @throws DownloadErrorException
 * @throws DbxException
 */
public String downloadFile(String dboxFilename) throws IOException, DownloadErrorException, DbxException {
	File tmpFile = File.createTempFile("dropbox-downloaded-file", ".tmp"); 
	DbxDownloader<FileMetadata> download = dboxClient.files().download(dboxFilename);
	OutputStream fOut = new FileOutputStream(tmpFile);
	download.download(fOut );
	String filePath = tmpFile.getAbsolutePath();
	fOut.close();
	return filePath;
}
 
开发者ID:boly38,项目名称:mongodbdump-java-wrapper,代码行数:18,代码来源:DropboxServiceImpl.java


示例5: getEvent

import com.dropbox.core.DbxDownloader; //导入依赖的package包/类
@Override
public Optional<MotionEvent> getEvent(String id) {
    MotionEvent motionEvent = motionEventStore.get(id);
    try {
        String dropboxPath = "/motion_events/" + concurrentDateFormatAccess.convertDateToString(motionEvent.getTimestamp());
        DbxDownloader<FileMetadata> dbxDownloader = dbxClientV2.files().download(dropboxPath + "/" + motionEvent.getId() + ".jpg");
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        dbxDownloader.download(byteArrayOutputStream);
        return Optional.of(new MotionEvent(id, motionEvent.getTimestamp(), byteArrayOutputStream.toByteArray()));
    } catch (Exception e) {
        log.error("Problem retrieving motion event: " + motionEvent.getId() + " from dropbox.", e);
        return Optional.empty();
    }
}
 
开发者ID:chriskearney,项目名称:eyeballs,代码行数:15,代码来源:DropBoxMotionEventPersistence.java


示例6: downloadFile

import com.dropbox.core.DbxDownloader; //导入依赖的package包/类
public void downloadFile(final String path, final OutputStream outputStream) {
    try {
        final DbxDownloader<FileMetadata> downloader = client.files().download(path);

        downloader.download(outputStream);
    } catch (final Exception ex) {
        LOG.error("Failed to download from Dropbox: " + path, ex);
        throw new DSyncClientException(ex);
    }
}
 
开发者ID:yuriytkach,项目名称:dsync-client,代码行数:11,代码来源:DropboxService.java


示例7: getServerSubscriptions

import com.dropbox.core.DbxDownloader; //导入依赖的package包/类
private Map<String, String> getServerSubscriptions() throws DbxException {
    final Map<String, String> subscriptions = new HashMap<>();
    DbxDownloader downloader = null;
    try {
        // Get subscription file and process it
        downloader = client.files().download(SUBSCRIPTION_LIST_FILE_PATH);
        Scanner scanner = new Scanner(downloader.getInputStream(), "UTF-8").useDelimiter("\\A");
        String[] lines = (scanner.hasNext() ? scanner.next() : "").split("\\r\\n?|\\n");

        for (String line : lines) {
            String[] parts = line.split("\\s", 2);
            // Each line has to have at least an URL, title is optional
            if (line.startsWith("http")) {
                final Podcast podcast = new Podcast(parts.length > 1 ? parts[1] : null, parts[0]);
                subscriptions.put(podcast.getUrl(), podcast.getName());
            }
        }
    } catch (DownloadErrorException dee) {
        // If our feed file does not yet exist, return empty map
        // Otherwise:
        if (!dee.errorValue.isPath())
            throw dee;
    } finally {
        if (downloader != null)
            downloader.close();
    }

    return subscriptions;
}
 
开发者ID:salema,项目名称:Podcatcher-Deluxe-Android-Studio,代码行数:30,代码来源:DropboxPodcastListSyncController.java


示例8: load

import com.dropbox.core.DbxDownloader; //导入依赖的package包/类
@Override
public Result load(Request request, int networkPolicy) throws IOException {

    try {
        DbxDownloader<FileMetadata> downloader =
                mDbxClient.files().getThumbnailBuilder(request.uri.getPath())
                        .withFormat(ThumbnailFormat.JPEG)
                        .withSize(ThumbnailSize.W1024H768)
                        .start();

        return new Result(downloader.getInputStream(), Picasso.LoadedFrom.NETWORK);
    } catch (DbxException e) {
        throw new IOException(e);
    }
}
 
开发者ID:dropbox,项目名称:dropbox-sdk-java,代码行数:16,代码来源:FileThumbnailRequestHandler.java


示例9: testUploadAndDownload

import com.dropbox.core.DbxDownloader; //导入依赖的package包/类
private void testUploadAndDownload(DbxClientV2 client) throws Exception {
    byte [] contents = ITUtil.randomBytes(1024);
    String filename = "testUploadAndDownload.dat";
    String path = ITUtil.path(getClass(), "/" + filename);

    FileMetadata metadata = client.files().uploadBuilder(path)
        .withAutorename(false)
        .withMode(WriteMode.ADD)
        .withMute(true)
        .uploadAndFinish(new ByteArrayInputStream(contents));

    assertEquals(metadata.getName(), filename);
    assertEquals(metadata.getPathLower(), path.toLowerCase());
    assertEquals(metadata.getSize(), contents.length);

    Metadata actual = client.files().getMetadata(path);
    assertTrue(actual instanceof FileMetadata, actual.getClass().getCanonicalName());
    assertEquals(actual, metadata);

    DbxDownloader<FileMetadata> downloader = client.files().download(path);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    downloader.download(out);

    byte [] actualContents = out.toByteArray();
    FileMetadata actualResult = downloader.getResult();

    assertEquals(actualResult, metadata);
    assertEquals(actualContents, contents);

    Metadata deleted = client.files().delete(path);
    assertEquals(deleted, metadata);
}
 
开发者ID:dropbox,项目名称:dropbox-sdk-java,代码行数:33,代码来源:DbxClientV2IT.java


示例10: testRetryDownload

import com.dropbox.core.DbxDownloader; //导入依赖的package包/类
@Test
public void testRetryDownload() throws Exception {
    HttpRequestor mockRequestor = mock(HttpRequestor.class);
    DbxRequestConfig config = createRequestConfig()
        .withAutoRetryEnabled(3)
        .withHttpRequestor(mockRequestor)
        .build();

    DbxClientV2 client = new DbxClientV2(config, "fakeAccessToken");
    FileMetadata expectedMetadata = constructFileMetadate();
    byte [] expectedBytes = new byte [] { 1, 2, 3, 4 };

    // 503 once, then return 200
    HttpRequestor.Uploader mockUploader = mockUploader();
    when(mockUploader.finish())
        .thenReturn(createEmptyResponse(503))
        .thenReturn(createDownloaderResponse(expectedBytes, serialize(expectedMetadata)));
    when(mockRequestor.startPost(anyString(), anyHeaders()))
        .thenReturn(mockUploader);

    DbxDownloader<FileMetadata> downloader = client.files().download(expectedMetadata.getId());

    // should have been attempted twice
    verify(mockRequestor, times(2)).startPost(anyString(), anyHeaders());

    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    FileMetadata actualMetadata = downloader.download(bout);
    byte [] actualBytes = bout.toByteArray();

    assertEquals(actualBytes, expectedBytes);
    assertEquals(actualMetadata, expectedMetadata);
}
 
开发者ID:dropbox,项目名称:dropbox-sdk-java,代码行数:33,代码来源:DbxClientV2Test.java


示例11: getFileDownloader

import com.dropbox.core.DbxDownloader; //导入依赖的package包/类
public DbxDownloader<Files.FileMetadata> getFileDownloader(String path) throws DbxException {
    return dropbox.dbxClientV2.files.downloadBuilder(path).start();
}
 
开发者ID:DevWars,项目名称:devwars.tv,代码行数:4,代码来源:FileStorage.java


示例12: start

import com.dropbox.core.DbxDownloader; //导入依赖的package包/类
/**
 * Issues the download request using this builder's request parameters and returns a {@link
 * DbxDownloader} for reading the response body.
 *
 * Callers should fully read the response body using {@link DbxDownloader#getInputStream} and
 * close the downloader afterwards (see {@link DbxDownloader#close}). This will allow for proper
 * resource deallocation and connection re-use..
 *
 * See {@link #download} convenience method for a simpler way to complete the request.
 *
 * @return {@link DbxDownloader} used to download data and read the response.
 *
 * @throws DbxException if an error occursing issuing the request
 */
public abstract DbxDownloader<R> start() throws DbxException;
 
开发者ID:dropbox,项目名称:dropbox-sdk-java,代码行数:16,代码来源:DbxDownloadStyleBuilder.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SnmpDataTypeEnums类代码示例发布时间:2022-05-22
下一篇:
Java TagAttribute类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap