Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.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 驱动器REST API插入错误,错误显示请求太长_Java_Google App Engine_Google Drive Api - Fatal编程技术网

Java 驱动器REST API插入错误,错误显示请求太长

Java 驱动器REST API插入错误,错误显示请求太长,java,google-app-engine,google-drive-api,Java,Google App Engine,Google Drive Api,在执行以下代码时,由于请求太大,我收到了错误 File body = new File(); body.setTitle(filename); body.setDescription(""); body.setMimeType(info.getContentType()); body.setFileSize(size); body.setMd5Checksum(chk); body.set("content", myFile); if

在执行以下代码时,由于请求太大,我收到了错误

 File body = new File();
    body.setTitle(filename);
    body.setDescription("");
    body.setMimeType(info.getContentType());
    body.setFileSize(size);
    body.setMd5Checksum(chk);
    body.set("content", myFile);

    if (parentId != null && parentId.length() > 0) {
        body.setParents(Arrays.asList(new ParentReference().setId(parentId
                .trim().toString())));
    }
    ByteArrayContent content = new ByteArrayContent(info.getContentType(),
            myFile);
    File upfile = service.files().insert(body, content).execute();
我在插入时出错。我只更新了4MB的文件到硬盘


请给我这个ot的解决方案,以任何改变的方式来实现这个功能

使用它特定于较大的文件:)

您可以通过配置Java库的MediaHttpUploader来设置可恢复的上载

insert.getMediaHttpUploader().setDirectUploadEnabled(false);
insert.getMediaHttpUploader().setChunkSize(MediaHttpUploader.MINIMUM_CHUNK_SIZE);
这样,分块上传的内容由MediaHttpUploader进行内部管理

如中所示,您还可以设置一个自定义的
MediaHttpUploaderProgressListener
来监视上载