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

Java DropboxServerException类代码示例

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

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



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

示例1: createPhotoFolder

import com.dropbox.client2.exception.DropboxServerException; //导入依赖的package包/类
/**
 * Creates a directory for photos if one does not already exist. If the folder already exists, this call will
 * do nothing.
 *
 * @param dropboxApi the {@link DropboxAPI}.
 * @return true if the directory is created or it already exists; false otherwise.
 */
private boolean createPhotoFolder(DropboxAPI<AndroidAuthSession> dropboxApi) {
    boolean folderCreated = false;
    if (dropboxApi != null) {
        try {
            dropboxApi.createFolder(mContext.getString(R.string.wings_dropbox__photo_folder));
            folderCreated = true;
        } catch (DropboxException e) {
            // Consider the folder created if the folder already exists.
            if (e instanceof DropboxServerException) {
                folderCreated = DropboxServerException._403_FORBIDDEN == ((DropboxServerException) e).error;
            }
        }
    }
    return folderCreated;
}
 
开发者ID:groundupworks,项目名称:wings,代码行数:23,代码来源:DropboxEndpoint.java


示例2: notFoundException

import com.dropbox.client2.exception.DropboxServerException; //导入依赖的package包/类
private DropboxServerException notFoundException() {
    HttpResponseFactory factory = new DefaultHttpResponseFactory();
    HttpResponse response = factory.newHttpResponse(new BasicStatusLine(
            HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_FOUND, null), null);
    return new DropboxServerException(response);
}
 
开发者ID:GoogleCloudPlatform,项目名称:endpoints-codelab-android,代码行数:7,代码来源:DropboxFileDownloaderTest.java


示例3: upload

import com.dropbox.client2.exception.DropboxServerException; //导入依赖的package包/类
/**
 * Uploads multiple chunks of data to the server until the upload is complete or an
 * error occurs.
 *
 * This method makes multiple requests to Dropbox, uploading multiple chunks of data
 * from the given ChunkedUploader's input stream. In the event of a network error or
 * a server error, an IOException or DropboxServerException respectively will be thrown.
 * This gives the user an opportunity to resume the upload by calling this method again,
 * or aborting and abandoning it.
 *
 * @param listener A ProgressListener (can be {@code null}) that will be notified of upload
 *                 progress.  The progress notifications will be for the entire file.
 *
 * @throws DropboxException If there was a transmission error
 * @throws IOException If there was a problem reading from the given InputStream.
 * @throws DropboxPartialFileException if the request was canceled before completion.
 */
public void upload(ProgressListener listener) throws DropboxException, IOException {
    while (offset < targetLength) {

        int nextChunkSize = (int)Math.min(chunkSize, targetLength - offset);

        ProgressListener adjustedListener = null;
        if (listener != null) {
            adjustedListener = new ProgressListener.Adjusted(listener, offset, targetLength);
        }

        if (lastChunk == null) {
            lastChunk = new byte[nextChunkSize];
            int bytesRead = stream.read(lastChunk);
            if (bytesRead < lastChunk.length) {
                throw new IllegalStateException("InputStream ended after " + (offset + bytesRead) + " bytes, expecting " + targetLength + " bytes.");
            }
        }
        try {
            synchronized(this) {
                if(!active) {
                    throw new DropboxPartialFileException(0);
                }
                lastRequest = chunkedUploadRequest(new ByteArrayInputStream(lastChunk), lastChunk.length, adjustedListener, offset, uploadId);
            }

            ChunkedUploadResponse resp = lastRequest.upload();

            this.offset = resp.getOffset();
            this.uploadId = resp.getUploadId();
            lastChunk = null;
        } catch (DropboxServerException e) {
            if (e.body.fields.containsKey("offset")) {
                long newOffset = (Long)e.body.fields.get("offset");
                if (newOffset > offset) {
                    lastChunk = null;
                    offset = newOffset;
                } else {
                    throw e;
                }
            } else {
                throw e;
            }
        }
    }



}
 
开发者ID:timezra,项目名称:dropbox-java-sdk,代码行数:66,代码来源:DropboxAPI.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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