上传大文件时Google Drive API卡住了

时间:2013-12-03 17:59:15

标签: java google-drive-api google-eclipse-plugin

当我上传文件时,有时候它会粘在一个大文件上的时间比预期的要长得多。它上传以前的文件确定,但它总是卡在这个26MB文件。上传应该只需要3分钟,但它运行3个多小时,在任务管理器中使用最大上传带宽,以及403 Unauthorized或'java.io.IOException:意外结束流'的错误 - 只是随机错误。我正在使用私钥上传到Google服务帐户。我正在使用Google Eclipse插件,并通过Eclipse插件添加了Drive API。我唯一能想到的是通过Fiddler2 / 4代理运行它来排除故障,但我不应该这样做。

代码

        BufferedInputStream bis = new BufferedInputStream(new FileInputStream(f));
        System.out.println("type of file "+f.getName()+":"+type + ", length:"+f.length());
        File driveFile = DriveService.insertFile(name, type, Constants.DOC_TYPE_PRIMARY, bis);

public static File insertFile(String name, String type, String docType, InputStream inputStream) throws IOException, Exception
{
    File file = new File();
    file.setTitle(name);
    file.setMimeType(type);
    file.setDescription(docType);

    List<ParentReference> parents = new ArrayList<ParentReference>(); //create parent ref
    parents.add(new ParentReference().setId(Constants.DRIVE_FOLDER_IDS.get(docType)));
    file.setParents(parents);

    InputStreamContent isc = new InputStreamContent(type, inputStream);
    File retval = getService().files().insert(file, isc).execute();

    //apply domain reader access
    enableDomainReaderAccess(retval.getId());

    return retval;
}

日志

type of file MWV Soda Packaging Report_First Draft.pptx:null, length:26373917

更多错误

Exception in thread "main" com.google.api.client.googleapis.json.GoogleJsonResponseException: 500 Internal Server Error
{
  "code" : 500,
  "errors" : [ {
    "domain" : "global",
    "message" : "Internal Error",
    "reason" : "internalError"
  } ],
  "message" : "Internal Error"
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:423)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
at com.mwv.pic.service.DriveService.insertFile(DriveService.java:167)



type of file Report Soda.ppt:application/vnd.openxmlformats-officedocument.presentationml.presentation, length:9103360
Exception in thread "main" java.io.IOException: insufficient data written
at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.close(HttpURLConnection.java:3213)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:81)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:964)
at com.google.api.client.googleapis.media.MediaHttpUploader.executeCurrentRequest(MediaHttpUploader.java:559)
at com.google.api.client.googleapis.media.MediaHttpUploader.resumableUpload(MediaHttpUploader.java:434)
at com.google.api.client.googleapis.media.MediaHttpUploader.upload(MediaHttpUploader.java:345)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:418)

版本

谷歌-API服务驱动-V2-rev107-1.16.0-rc.jar

0 个答案:

没有答案