首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google,Meta-Data

Google,Meta-Data
EN

Stack Overflow用户
提问于 2015-03-31 20:04:30
回答 1查看 424关注 0票数 1

我正在成功上传文件到谷歌驱动器,但我的元数据似乎没有得到正确的回我。

代码语言:javascript
复制
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语句,下面是我发送的关于该文档的详细信息。

{description=XXXXXXX发票,fileExtension=pdf,indexableText={text=XXXXXXX发票},labels={restricted=false},mimeType=application/pdf,parents={id=0B_owsnWRsIy7S1VsWG1vNTYzM1k},properties={key=DocumentType,value=11},title=XXXXXXX发票}

当我使用以下代码为同一个文档做get时

代码语言:javascript
复制
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;
    }
}

我得到的大部分文本减去可索引的文本和文件扩展名,这是正确的(不想显示,因为它包含了大量的信息是噪音)?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-03-31 20:24:58

这里有两个独立的问题.

1) fileExtension是一个只读字段,因此被忽略。检索信息时,它是从原始标题/文件名派生出来的。因为您的标题不包括".pdf“,所以它被设置为空。

2) indexableText是只写的,我们不允许您在设置之后检索它;它仅由驱动器后端用于服务搜索查询。

您可以更多地了解文档中的文件资源的不同元数据属性。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29377568

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档