com.google.api.services.drive.model.File.getParents()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中com.google.api.services.drive.model.File.getParents()方法的一些代码示例,展示了File.getParents()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。File.getParents()方法的具体详情如下:
包路径:com.google.api.services.drive.model.File
类名称:File
方法名:getParents

File.getParents介绍

[英]The IDs of the parent folders which contain the file. If not specified as part of a create request, the file will be placed directly in the user's My Drive folder. If not specified as part of a copy request, the file will inherit any discoverable parents of the source file. Update requests must use the addParents and removeParents parameters to modify the parents list.
[中]包含该文件的父文件夹的ID。如果未指定为创建请求的一部分,则文件将直接放置在用户的“我的驱动器”文件夹中。如果未指定为复制请求的一部分,则该文件将继承源文件的任何可发现父级。更新请求必须使用addParents和removeParents参数来修改父列表。

代码示例

代码示例来源:origin: org.talend.components/components-googledrive-runtime

@Override
public Map<String, Object> getReturnValues() {
  Map<String, Object> r = result.toMap();
  r.put(GoogleDrivePutDefinition.RETURN_FILE_ID, sentFile.getId());
  r.put(GoogleDrivePutDefinition.RETURN_PARENT_FOLDER_ID, sentFile.getParents().get(0));
  return r;
}

代码示例来源:origin: Talend/components

@Override
public Map<String, Object> getReturnValues() {
  Map<String, Object> r = result.toMap();
  r.put(GoogleDrivePutDefinition.RETURN_FILE_ID, sentFile.getId());
  r.put(GoogleDrivePutDefinition.RETURN_PARENT_FOLDER_ID, sentFile.getParents().get(0));
  return r;
}

代码示例来源:origin: Talend/components

private void setReturnValues(RuntimeContainer container) {
    String componentId = container.getCurrentComponentId();
    container.setComponentData(componentId, getStudioName(GoogleDrivePutDefinition.RETURN_PARENT_FOLDER_ID),
        sentFile.getParents().get(0));
    container.setComponentData(componentId, getStudioName(GoogleDrivePutDefinition.RETURN_FILE_ID), sentFile.getId());
  }
}

代码示例来源:origin: org.talend.components/components-googledrive-runtime

private void setReturnValues(RuntimeContainer container) {
    String componentId = container.getCurrentComponentId();
    container.setComponentData(componentId, getStudioName(GoogleDrivePutDefinition.RETURN_PARENT_FOLDER_ID),
        sentFile.getParents().get(0));
    container.setComponentData(componentId, getStudioName(GoogleDrivePutDefinition.RETURN_FILE_ID), sentFile.getId());
  }
}

代码示例来源:origin: Talend/components

record.put(0, bytes);
record.put(1, sentFile.getParents().get(0));
record.put(2, sentFile.getId());
cleanWrites();

代码示例来源:origin: org.talend.components/components-googledrive-runtime

record.put(0, bytes);
record.put(1, sentFile.getParents().get(0));
record.put(2, sentFile.getId());
cleanWrites();

代码示例来源:origin: org.talend.components/components-googledrive-runtime

@Override
public boolean start() throws IOException {
  super.start();
  String localFilePath = properties.localFilePath.getValue();
  String destinationFolderId = properties.destinationFolderAccessMethod.getValue().equals(AccessMethod.Id)
      ? properties.destinationFolder.getValue()
      : utils.getFolderId(properties.destinationFolder.getValue(), false);
  GoogleDrivePutParameters p = new GoogleDrivePutParameters(destinationFolderId, properties.fileName.getValue(),
      properties.overwrite.getValue(), localFilePath);
  sentFile = utils.putResource(p);
  record = new Record(properties.schemaMain.schema.getValue());
  record.put(0, java.nio.file.Files.readAllBytes(Paths.get(localFilePath)));
  record.put(1, sentFile.getParents().get(0));
  record.put(2, sentFile.getId());
  result.totalCount++;
  result.successCount++;
  return true;
}

代码示例来源:origin: Talend/components

@Override
public boolean start() throws IOException {
  super.start();
  String localFilePath = properties.localFilePath.getValue();
  String destinationFolderId = properties.destinationFolderAccessMethod.getValue().equals(AccessMethod.Id)
      ? properties.destinationFolder.getValue()
      : utils.getFolderId(properties.destinationFolder.getValue(), false);
  GoogleDrivePutParameters p = new GoogleDrivePutParameters(destinationFolderId, properties.fileName.getValue(),
      properties.overwrite.getValue(), localFilePath);
  sentFile = utils.putResource(p);
  record = new Record(properties.schemaMain.schema.getValue());
  record.put(0, java.nio.file.Files.readAllBytes(Paths.get(localFilePath)));
  record.put(1, sentFile.getParents().get(0));
  record.put(2, sentFile.getId());
  result.totalCount++;
  result.successCount++;
  return true;
}

代码示例来源:origin: andresoviedo/google-drive-ftp-adapter

private GFile create(File file) {
  GFile newFile = new GFile(file.getName() != null ? file.getName() : file.getOriginalFilename());
  newFile.setId(file.getId());
  newFile.setLastModified(file.getModifiedTime() != null ? file.getModifiedTime().getValue() : 0);
  newFile.setDirectory(GFile.MIME_TYPE.GOOGLE_FOLDER.getValue().equals(file.getMimeType()));
  newFile.setSize(file.getSize() != null ? file.getSize() : 0); // null for directories
  newFile.setMimeType(file.getMimeType());
  newFile.setMd5Checksum(file.getMd5Checksum());
  if (file.getParents() != null) {
    Set<String> newParents = new HashSet<>();
    for (String newParent : file.getParents()) {
      newParents.add(newParent.equals(ROOT_FOLDER_ID) ? "root" : newParent);
    }
    newFile.setParents(newParents);
  } else {
    // does this happen?
    newFile.setParents(Collections.singleton("root"));
  }
  newFile.setTrashed(file.getTrashed() != null && file.getTrashed());
  return newFile;
}

代码示例来源:origin: org.talend.components/components-googledrive-runtime

private IndexedRecord convertSearchResultToIndexedRecord(File file) {
  // Main record
  IndexedRecord main = new GenericData.Record(schema);
  main.put(0, file.getId());
  main.put(1, file.getName());
  main.put(2, file.getMimeType());
  main.put(3, file.getModifiedTime().getValue());
  main.put(4, file.getSize());
  main.put(5, file.getKind());
  main.put(6, file.getTrashed());
  main.put(7, file.getParents().toString()); // TODO This should be a List<String>
  main.put(8, file.getWebViewLink());
  return main;
}

代码示例来源:origin: Talend/components

private IndexedRecord convertSearchResultToIndexedRecord(File file) {
  // Main record
  IndexedRecord main = new GenericData.Record(schema);
  main.put(0, file.getId());
  main.put(1, file.getName());
  main.put(2, file.getMimeType());
  main.put(3, file.getModifiedTime().getValue());
  main.put(4, file.getSize());
  main.put(5, file.getKind());
  main.put(6, file.getTrashed());
  main.put(7, file.getParents().toString()); // TODO This should be a List<String>
  main.put(8, file.getWebViewLink());
  return main;
}

代码示例来源:origin: iterate-ch/cyberduck

.setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable"))
  .execute();
for(String parent : reference.getParents()) {
  previousParents.append(parent);
  previousParents.append(',');

相关文章