Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/344.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 上载大文件时Google Drive API卡住_Java_Google Drive Api_Google Eclipse Plugin - Fatal编程技术网

Java 上载大文件时Google Drive API卡住

Java 上载大文件时Google Drive API卡住,java,google-drive-api,google-eclipse-plugin,Java,Google Drive Api,Google Eclipse Plugin,当我上传文件时,有时它会在一个大文件上停留更长的时间。它可以上传以前的文件,但总是停留在这个26MB的文件上。上载应该只需要3分钟,但它会运行3个多小时,在任务管理器中使用最大上载带宽,并且错误为403未经授权或“java.io.IOException:意外的流结束”-只是随机错误。我正在使用私钥上传到Google服务帐户。我正在使用GoogleEclipse插件,并通过Eclipse插件添加了驱动API。我唯一能想到的就是通过Fiddler2/4代理运行它来进行故障排除,但我不应该这样做 代码

当我上传文件时,有时它会在一个大文件上停留更长的时间。它可以上传以前的文件,但总是停留在这个26MB的文件上。上载应该只需要3分钟,但它会运行3个多小时,在任务管理器中使用最大上载带宽,并且错误为403未经授权或“java.io.IOException:意外的流结束”-只是随机错误。我正在使用私钥上传到Google服务帐户。我正在使用GoogleEclipse插件,并通过Eclipse插件添加了驱动API。我唯一能想到的就是通过Fiddler2/4代理运行它来进行故障排除,但我不应该这样做

代码 更多错误 版本
google-api-services-drive-v2-rev107-1.16.0-rc.jar

检查这一点,DaImTo-Naa可能也有同样的问题,不是这样。它会在一个文件上停留很长一段时间,不会做很多事情,然后会抛出一个错误。没有快速连续的文件。我试了好几次,在同一个文件上得到了相同的结果。它根本没有加载服务器,因为我的连接速度不快。它在一个同事系统上工作,不同的网络。500错误是一个一般的服务器错误,我在谷歌分析中得到它,当服务器正忙的时候。您是否尝试添加了执行指数退避?我添加了这一点,当我的代码达到7时,它对我起到了作用。我如何实现指数退避?只有一个文件。失败需要3个小时,但它使用带宽。我日日夜夜都试过了。指数级的等待时间是6小时,然后是12小时,然后是一整天!那太疯狂了!你不需要等那么久再尝试。
        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)