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

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

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

File.getId介绍

[英]The ID of the file.
[中]文件的ID。

代码示例

代码示例来源:origin: apache/incubator-gobblin

private FileStatus toFileStatus(File metadata) {
 return new FileStatus(metadata.getSize() == null ? 0L : metadata.getSize(),
            FOLDER_MIME_TYPE.equals(metadata.getMimeType()),
            -1,
            -1,
            metadata.getModifiedTime().getValue(),
            new Path(metadata.getId()));
}

代码示例来源:origin: google/data-transfer-project

private String importSingleFolder(
  UUID jobId,
  Drive driveInterface,
  String folderName,
  String folderId,
  String parentId) throws IOException {
 File newFolder = new File()
   .setName(folderName)
   .setMimeType(DriveExporter.FOLDER_MIME_TYPE);
 if (!Strings.isNullOrEmpty(parentId)) {
  newFolder.setParents(ImmutableList.of(parentId));
 }
 File resultFolder = driveInterface.files().create(newFolder).execute();
 DriveFolderMapping mapping = new DriveFolderMapping(folderId, resultFolder.getId());
 jobStore.update(jobId, folderId, mapping);
 return resultFolder.getId();
}

代码示例来源:origin: pentaho/pentaho-kettle

protected void doCreateFolder() throws Exception {
 if ( !getName().getBaseName().isEmpty() ) {
  File folder = new File();
  folder.setName( getName().getBaseName() );
  folder.setMimeType( MIME_TYPES.FOLDER.mimeType );
  folder = driveService.files().create( folder ).execute();
  if ( folder != null ) {
   id = folder.getId();
   mimeType = MIME_TYPES.get( folder.getMimeType() );
  }
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

private void resolveFileMetadata() throws Exception {
 String parentId = null;
 if ( getName().getParent() != null ) {
  File parent = searchFile( getName().getParent().getBaseName(), null );
  if ( parent != null ) {
   FileType mime = MIME_TYPES.get( parent.getMimeType() );
   if ( mime.equals( FileType.FOLDER ) ) {
    parentId = parent.getId();
   }
  }
 }
 String fileName = getName().getBaseName();
 File file = searchFile( fileName, parentId );
 if ( file != null ) {
  mimeType = MIME_TYPES.get( file.getMimeType() );
  id = file.getId();
 } else {
  if ( getName().getURI().equals( GoogleDriveFileProvider.SCHEME + ":///" ) ) {
   mimeType = FileType.FOLDER;
  }
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

public void close() throws IOException {
  File file = new File();
  file.setName( getName().getBaseName() );
  if ( parent != null ) {
   file.setParents( Collections.singletonList( parent.getId() ) );
  }
  ByteArrayContent fileContent = new ByteArrayContent( "application/octet-stream", toByteArray() );
  if ( count > 0 ) {
   driveService.files().create( file, fileContent ).execute();
   ( (GoogleDriveFileSystem) getFileSystem() ).clearFileFromCache( getName() );
  }
 }
};

代码示例来源:origin: google/data-transfer-project

folders.add(new BlobbyStorageContainerResource(file.getName(), file.getId(), null, null));
} else if (FUSION_TABLE_MIME_TYPE.equals(file.getMimeType())) {
 monitor.info(() -> "Exporting of fusion tables is not yet supported: " + file);
     driveInterface
       .files()
       .export(file.getId(), newMimeType)
       .executeMedia()
       .getContent();
     driveInterface
       .files()
       .get(file.getId())
       .setAlt("media")
       .executeMedia()
       .getContent();
  jobStore.create(jobId, file.getId(), inputStream);
  files.add(
    new DigitalDocumentWrapper(
        file.getName(), file.getModifiedTime().toStringRfc3339(), newMimeType),
      file.getMimeType(),
      file.getId()));
 } catch (Exception e) {
  monitor.severe(() -> "Error exporting " + file, e);

代码示例来源:origin: com.github.robozonky/robozonky-integration-stonky

private File modifySpreadsheet(final File original, final java.io.File export) throws IOException {
  final String id = original.getId();
  LOGGER.debug("Updating an existing Google spreadsheet: {}.", id);
  final File result = actuallyModifySpreadsheet(original, export);
  LOGGER.debug("Google spreadsheet updated.");
  return result;
}

代码示例来源:origin: siom79/jdrivesync

public boolean isGoogleAppsDocument(File file) {
  String mimeType = file.getMimeType();
  if (mimeType != null && mimeType.startsWith("application/vnd.google-apps") && !mimeType.equals("application/vnd.google-apps.folder")) {
    LOGGER.log(Level.FINE, "Not touching file " + file.getId() + " because it is a Google Apps document.");
    return true;
  }
  return false;
}

代码示例来源:origin: RoboZonky/robozonky

private File modifySpreadsheet(final File original, final java.io.File export) throws IOException {
  final String id = original.getId();
  LOGGER.debug("Updating an existing Google spreadsheet: {}.", id);
  final File result = actuallyModifySpreadsheet(original, export);
  LOGGER.debug("Google spreadsheet updated.");
  return result;
}

代码示例来源: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: RoboZonky/robozonky

@Override
protected boolean appliesTo(final String method, final String url) {
  return Objects.equals(method, "POST") &&
      Objects.equals(url, "https://sheets.googleapis.com/v4/spreadsheets/" + parent.getId() + ":batchUpdate");
}

代码示例来源:origin: RoboZonky/robozonky

@Override
protected boolean appliesTo(final String method, final String url) {
  return Objects.equals(method, "GET") &&
      url.startsWith("https://www.googleapis.com/drive/v3/files/" + file.getId());
}

代码示例来源:origin: org.apache.gobblin/google-ingestion

private FileStatus toFileStatus(File metadata) {
 return new FileStatus(metadata.getSize() == null ? 0L : metadata.getSize(),
            FOLDER_MIME_TYPE.equals(metadata.getMimeType()),
            -1,
            -1,
            metadata.getModifiedTime().getValue(),
            new Path(metadata.getId()));
}

代码示例来源:origin: com.github.robozonky/robozonky-integration-stonky

private static Stream<File> getFilesInFolder(final Drive driveService, final String parentId) throws IOException {
  LOGGER.debug("Listing files in folder {}.", parentId);
  return driveService.files().list()
      .setQ("'" + parentId + "' in parents and trashed = false")
      .setFields("nextPageToken, files(" + getFields("mimeType") + ")")
      .execute()
      .getFiles()
      .stream()
      .peek(f -> LOGGER.debug("Found '{}' ({}) as {}.", f.getName(), f.getMimeType(), f.getId()));
}

代码示例来源:origin: RoboZonky/robozonky

@Test
void updateWalletSpreadsheet() throws IOException {
  final DriveOverview overview = DriveOverview.create(SESSION_INFO, drive, sheets);
  // copy the spreadsheet since it does not exist
  final File result = overview.latestWallet(GoogleUtil.getDownloaded());
  assertThat(result.getId()).isEqualTo(walletSpreadsheet.getId());
}

代码示例来源: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: com.github.robozonky/robozonky-integration-stonky

private File actuallyModifySpreadsheet(final File original, final java.io.File export) throws IOException {
  final FileContent fc = new FileContent(MIME_TYPE_XLS_SPREADSHEET, export);
  return driveService.files().update(original.getId(), null, fc)
      .setFields(getFields())
      .execute();
}

代码示例来源:origin: RoboZonky/robozonky

@Override
  protected MockLowLevelHttpResponse respond(final String method, final String url) {
    /*
     *
     * "location" header handles the redirect from first part to second part, otherwise API will throw NPE. the
     * value given is synthetic and has no relation to anything that Google may put there.
     */
    return new MockLowLevelHttpResponse()
        .setContent(toJson(file))
        .addHeader("Location", ROOT + "?id=" + file.getId() + "uploadType=resumable");
  }
}

代码示例来源:origin: io.github.aktoluna/slnarch-common

public void shareFile(File file, String to) throws IOException {
 BatchRequest batch = drive.batch();
 Permission userPermission = new Permission()
   .setType("user")
   .setRole("writer")
   .setValue(to);
 drive.permissions().insert(file.getId(), userPermission)
   .setSendNotificationEmails(true)
   .setFields("id")
   .queue(batch, callback);
 batch.execute();
}

代码示例来源:origin: RoboZonky/robozonky

@BeforeEach
void prepareFolder() {
  transport = new MultiRequestMockHttpTransport();
  transport.addReponseHandler(new FilesInFolderResponseHandler("root", stonkyFolder));
  stonkyFolderContent = new FilesInFolderResponseHandler(stonkyFolder.getId());
  transport.addReponseHandler(stonkyFolderContent);
  drive = Util.createDriveService(credential, transport);
  sheets = Util.createSheetsService(credential, transport);
}

相关文章