将GAB Java中的blobstore文件上传到Dropbox

时间:2015-11-02 02:28:13

标签: java google-app-engine dropbox dropbox-api

我使用Blobstore在Google App Engine(Java)上保存了一个文件,需要将该文件上传到Dropbox。我使用Dropbox Java API代码,但使用Google App Engine中的代码时出现异常。我看过类似的帖子,但不是很好的答案。

核心问题:如何将文件从Blobstore上传到Dropbox?

我的代码:

BlobstoreInputStream bis = new BlobstoreInputStream(blobKey);
    BlobInfoFactory blobInfoFactory = new BlobInfoFactory();
    BlobInfo blobInfo = blobInfoFactory.loadBlobInfo(blobKey);
    Long blobSize = blobInfo.getSize();



    DbxAppInfo appInfo = new DbxAppInfo(APP_KEY, APP_SECRET);

    DbxRequestConfig config = new DbxRequestConfig(
        "JavaTutorial/1.0", Locale.getDefault().toString());
    DbxWebAuthNoRedirect webAuth = new DbxWebAuthNoRedirect(config, appInfo);

    DbxClient client = new DbxClient(config, accessToken);
    try {

        DbxEntry.File uploadedFile = client.uploadFile("/TestUpload.txt", DbxWriteMode.add(), blobSize, bis);

    } catch (Exception e) { e.printStackTrace(); }

例外: java.lang.ClassCastException:com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler $ Connection无法强制转换为javax.net.ssl.HttpsURLConnection     在com.dropbox.core.http.StandardHttpRequestor.prepRequest(StandardHttpRequestor.java:150)     在com.dropbox.core.http.StandardHttpRequestor.startPut(StandardHttpRequestor.java:83)     在com.dropbox.core.http.StandardHttpRequestor.startPut(StandardHttpRequestor.java:23)     在com.dropbox.core.DbxRequestUtil.startPut(DbxRequestUtil.java:137)     在com.dropbox.core.DbxClient.startUploadFileSingle(DbxClient.java:727)     在com.dropbox.core.DbxClient.startUploadFile(DbxClient.java:684)     在com.dropbox.core.DbxClient.uploadFile(DbxClient.java:626)     在com.dropbox.core.DbxClient.uploadFile(DbxClient.java:579)

0 个答案:

没有答案