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
来监视上载