當前位置: 首頁>>代碼示例>>Java>>正文


Java FileList.getItems方法代碼示例

本文整理匯總了Java中com.google.api.services.drive.model.FileList.getItems方法的典型用法代碼示例。如果您正苦於以下問題:Java FileList.getItems方法的具體用法?Java FileList.getItems怎麽用?Java FileList.getItems使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.api.services.drive.model.FileList的用法示例。


在下文中一共展示了FileList.getItems方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getOrCreateDriveFolder

import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
public static String getOrCreateDriveFolder(Drive drive, String targetFolder) throws IOException {
    String folderId = null;
    FileList folders = drive.files().list().setQ("mimeType='application/vnd.google-apps.folder'").execute();
    for (com.google.api.services.drive.model.File f : folders.getItems()) {
        if (f.getTitle().equals(targetFolder)) {
            folderId = f.getId();
        }
    }
    //if not found create it
    if (folderId == null) {
        com.google.api.services.drive.model.File body = new com.google.api.services.drive.model.File();
        body.setTitle(targetFolder);
        body.setMimeType("application/vnd.google-apps.folder");
        com.google.api.services.drive.model.File file = drive.files().insert(body).execute();
        folderId = file.getId();
    }
    return folderId;
}
 
開發者ID:tiberiusteng,項目名稱:financisto1-holo,代碼行數:19,代碼來源:GoogleDriveClient.java

示例2: getFiles

import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
/**
 * Gets all the files from a request.
 * 
 * @param request the request
 * @param excludeSharedWithMe true to exclude shared with me files
 * @return a map of file id to file
 */
private Map<String, File> getFiles(Files.List request, boolean excludeSharedWithMe)
    throws IOException {
  Map<String, File> idToFileMap = new HashMap<String, File>();
  do {
    FileList files = request.execute();

    for (File file : files.getItems()) {
      if (excludeSharedWithMe && file.getSharedWithMeDate() != null) {
        continue;
      }
      idToFileMap.put(file.getId(), file);
    }
    request.setPageToken(files.getNextPageToken());
  } while (request.getPageToken() != null && request.getPageToken().length() > 0);
  return idToFileMap;
}
 
開發者ID:Plonk42,項目名稱:mytracks,代碼行數:24,代碼來源:SyncAdapter.java

示例3: loadTreeNode

import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
public void loadTreeNode(File node) {

		checkController();

		if (node == null) {
			TreeItem<File> root = createNode (null);
			try {
				FileList dirs = DriveUtils.findDirectories(drive, null, null);
				for (File dir : dirs.getItems()) {
					root.getChildren().add(createNode(dir));
				}
				driveTreeView.setRoot(root);
			} catch (IOException e) {
				logger.error("Error occurred while loading the tree view", e);
			}
		}
	}
 
開發者ID:roikku,項目名稱:drive-uploader,代碼行數:18,代碼來源:DriveDirectoryChooserViewController.java

示例4: createDirectoryIfNotExist

import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
private static File createDirectoryIfNotExist (Drive client, final File parent, String title) throws Throwable {
	File driveDirectory = null ;
	AtomicInteger tryCounter = new AtomicInteger () ;
	while (true) {
		try {
			FileList dirs = DriveUtils.findDirectoriesWithTitle(client, title, DriveUtils.newId(parent), (Integer)null) ;
			if (dirs.getItems() == null || dirs.getItems().isEmpty()) {
				logger.info(
						String.format("The directory %s does not exists%s. It will be created.",
						title,
						((parent == null) ? ("") : (" (under " + parent.getTitle() + ")"))));
				driveDirectory = DriveUtils.insertDirectory(client, title, null, DriveUtils.newId(parent));
			} else if (dirs.getItems().size() > 1) {
				throw new IllegalStateException ("There are " + dirs.size() + " directories with the name " + title + "...") ;
			} else {
				driveDirectory = dirs.getItems().get(0) ;		
			}
			break ;
		} catch (Throwable e) {
			dealWithException (e, tryCounter) ;
		}
	}
	return driveDirectory ;
}
 
開發者ID:roikku,項目名稱:drive-uploader,代碼行數:25,代碼來源:DriveOperations.java

示例5: getFileId

import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
/**
     * Retrieve a suitable file to open our browserchannel with
     *
     * @param service
     * @return
     * @throws Exception
     */
    private static String getFileId(Drive service) throws Exception
    {
        String fileName = null;
        String fileId = null;
        FileList files = service.files().list().execute();
        for (File file : files.getItems()) {
            if (file.getMimeType().equals(APP_MIME_TYPE + "." + appId)) {
                fileId = file.getId();
                fileName = file.getTitle();
                break;
            }
        }

        logger.debug("FileID: {}", fileId);
        logger.debug("FileName: {}", fileName);

        if (fileId == null) {
            throw new Exception("No Realtime file found");
            // Add file
//            fileId = addRealtimeFile(service);
        }

        return fileId;
    }
 
開發者ID:mkrause,項目名稱:gx,代碼行數:32,代碼來源:BrowserChannelTest.java

示例6: fileInList

import com.google.api.services.drive.model.FileList; //導入方法依賴的package包/類
private boolean fileInList(String fileId, FileList fileList) {
    for (File f : fileList.getItems()) {
        if (f.getId().equals(fileId)) {
            return true;
        }
    }
    return false;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:9,代碼來源:FilesConsumerIntegrationTest.java


注:本文中的com.google.api.services.drive.model.FileList.getItems方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。