Google drive api 谷歌驱动API,元数据
我正在成功地将文档上传到Google Drive,但我的元数据似乎没有正确返回给我Google drive api 谷歌驱动API,元数据,google-drive-api,Google Drive Api,我正在成功地将文档上传到Google Drive,但我的元数据似乎没有正确返回给我 protected File insertFile(Drive service, List<String> parentIds, com.google.drive.FileContent fileContent, File googleFile)throws IOException { // Set the parent folder. if (parentIds != null &&
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;
}
}
我得到的大部分文本减去可索引文本和文件扩展名,是否正确(不想显示,因为它包含大量噪音信息)?这里有两个独立的问题。 1)
fileExtension
是只读字段,因此被忽略。检索信息时,它是从原始标题/文件名派生的。由于您的标题不包含“.pdf”,因此将其设置为空
2) indexableText
仅在中写入,我们不允许您在设置后检索它;它仅由驱动器后端用于服务搜索查询
您可以阅读有关的不同元数据属性的更多信息
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;
}
}