我将文档上传到Google云端硬盘已成功,但我的元数据似乎没有正确回复我。Google Drive API,元数据
protected File insertFile(Drive service, List<String> parentIds, com.google.drive.FileContent fileContent, File googleFile)throws IOException {
// Set the parent folder.
if (parentIds != null && parentIds.size() > 0) {
List<ParentReference> parentReferences = new ArrayList<ParentReference>();
for (String parentId : parentIds){
parentReferences.add(new ParentReference().setId(parentId));
}
googleFile.setParents(parentReferences);
}
try {
googleFile = service.files().insert(googleFile, fileContent).execute();
// Uncomment the following line to print the File ID.
System.out.println("File ID: " + googleFile.getId());
return googleFile;
}
catch (IOException e) {
System.out.println("An error occured: " + e);
return null;
}
}
上面是我的insert语句,下面是我发送的有关文档的详细信息。
{描述= XXXXXXX发票,fileExtension = PDF, indexableText = {文本= XXXXXXX发票},标签= {受限= FALSE}, mime类型=应用/ PDF,父母= [{ID = 0B_owsnWRsIy7S1VsWG1vNTYzM1k }], 属性= [{键= DocumentType,值= 11}],标题= XXXXXXX发票}
当我使用此代码
protected InputStream downloadFile(Drive service, File file)throws IOException {
if (file.getDownloadUrl() != null && file.getDownloadUrl().length() > 0) {
HttpResponse resp =
service.getRequestFactory().buildGetRequest(new GenericUrl(file.getDownloadUrl()))
.execute();
return resp.getContent();
}
else {
// The file doesn't have any content stored on Drive.
return null;
}
}
该相同文档做一个get
我将大部分文本减去可索引的文本和文件扩展名,是否正确(不想显示,因为它包含很多噪声信息)?