本文整理匯總了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;
}
示例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;
}
示例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);
}
}
}
示例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 ;
}
示例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;
}
示例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;
}