我需要列出用户驱动器云中的所有图像。
我使用 https://www.googleapis.com/drive/v2/files和正确的过滤器来查询所有图像。我需要将应用程序中的结果分组到文件夹中。我知道一个文件可以有多个父文件,这很好。
我想避免使用第一次调用中的父 ID通过https://developers.google.com/drive/v2/reference/files/get进行调用(对于每个单个文件一个调用)来获取文件文件夹。
是否有一种网络友好的方式来获取文件夹中包含的所有文件?
编辑
一种简单的解决方案是在一个查询中获取具有 id 的所有文件夹,并在此结果中查找文件夹名称。也许这有可能吗?
我正在制作类似在线日记应用程序的东西,它将从谷歌驱动器(通过共享链接)下载一次“日记文件”,并在该文件发生变化时更新该文件。请,任何人都可以指点我一些指南如何做到这一点。我已经尝试从驱动器固定文件,但我真的不明白接下来要做什么..
如果 FileID 遵循特定格式,例如新文件具有更高的值或更低的值,我可以跟踪旧值并找出我是否在驱动器中上传了新文件。
google-drive-api google-drive-realtime-api google-drive-android-api
我按照此文档将文件上传到 Google Drive: https: //developers.google.com/drive/android/files
现在,每次我想上传文件时,都会出现 Google Drive 的弹出窗口,询问我将其上传到哪里以及用哪个名字。我不想要那个弹出窗口,我想直接上传文件。
有什么方法可以做到这一点吗?我在文档中找不到任何内容。我也发现了: https: //developers.google.com/drive/api/v3/integrate-create,但我不知道是否可以使用它。你能给我一些提示吗?
编辑:
这是我的 build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://maven.google.com' }
} …Run Code Online (Sandbox Code Playgroud) 我是Google Drive Android API的新手,我正在学习它.但我遇到的问题是我无法使用Google Drive Android API删除文件,但没有一个例子.anybood可以帮我解决这个问题吗?非常感谢.
java android google-api google-drive-api google-drive-android-api
我正在使用Drive API,并开始变得非常沮丧.我正在尝试使用查询根据名称搜索文件/文件夹.这个演示有一个很好的例子来说明如何执行此操作:https://github.com/googledrive/android-demos/blob/master/src/com/google/android/gms/drive/sample/demo/QueryFilesWithAInTitleActivity.java
但我不想将数据添加到ListView,我只想直接从MetadataBufferResult中提取信息(标题和ID,以便我可以使用它们).但是我看过的每个例子都只是这个ListView的东西,而且我还没能找到从MetadataBufferResult中提取任何信息的方法或找到它的好文档.
基本上我希望能够这样做(代码取自上面链接的演示):
final private ResultCallback<DriveApi.MetadataBufferResult> metadataCallback =
new ResultCallback<DriveApi.MetadataBufferResult>() {
@Override
public void onResult(DriveApi.MetadataBufferResult result) {
if (!result.getStatus().isSuccess()) {
showMessage("Problem while retrieving results");
return;
}
//I haven't been able to find a way to do this
result.getDriveID();
result.getFileTitle();
}
};
Run Code Online (Sandbox Code Playgroud)
简短版本:我想在某人的Drive帐户的根目录中搜索标题为"x"的文件,然后读/写此文件.我的问题是我无法从我传递的MetadataBufferResult对象中提取数据,我看到的所有示例都使用ListView输出它,我不想这样做.
android google-drive-api google-play-services google-drive-android-api
运行下面的代码,我在平板电脑上创建了一个包含Google Drive Android API的文件夹.几秒钟后,从PC上的远程位置删除该文件夹.当我重新运行代码时,API仍然认为"MyFolder"存在,即使它已被删除且在平板电脑上的Google云端硬盘应用中不可见.文件夹持久性最终会在一段时间后消失,代码按预期工作.这是云驱动器的预期行为吗?
Query query = new Query.Builder()
.addFilter(Filters.and(Filters.eq(
SearchableField.TITLE, "MyFolder"),
Filters.eq(SearchableField.TRASHED, false)))
.build();
Drive.DriveApi.query(getGoogleApiClient(), query)
.setResultCallback(new ResultCallback<DriveApi.MetadataBufferResult>() {
@Override
public void onResult(DriveApi.MetadataBufferResult result) {
if (!result.getStatus().isSuccess()) {
showMessage("Cannot create folder in the root.");
} else {
boolean isFound = false;
for(Metadata m : result.getMetadataBuffer()) {
if(!isFound) {
if (m.getTitle().equals("MyFolder")) {
showMessage("Folder exists");
isFound = true;
}
}
}
if(!isFound) {
showMessage("Folder not found; creating it.");
MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
.setTitle("MyFolder")
.build();
Drive.DriveApi.getRootFolder(getGoogleApiClient())
.createFolder(getGoogleApiClient(), changeSet)
.setResultCallback(new ResultCallback<DriveFolder.DriveFolderResult>() { …Run Code Online (Sandbox Code Playgroud) 我正在将 Google Drive API 集成到我的 Android 应用程序中,以在 App Storage 文件夹中存储一个 JSON 文件。
为此,我在 MainActivity 的片段中实现了 Google Drive API。
当我执行此代码时,它按预期使用 SIGN_IN_REQUIRED 代码命中 onConnectionFailed 方法。我执行 startResolutionForResult 并出现帐户选择器。
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Log.i(TAG, "GoogleApiClient connection failed: " + connectionResult.toString());
if (connectionResult.hasResolution()) {
if(!mConnectionResolutionInProgress)
{
try {
mConnectionResolutionInProgress = true;
connectionResult.startResolutionForResult(getActivity(), REQUEST_CODE_RESOLUTION);
} catch (IntentSender.SendIntentException e) {
// Unable to resolve, message user appropriately
showMessage("There was an issue connecting to Google Drive services.");
}
}
else
{
mConnectionResolutionInProgress = false;
showMessage("Canceling export/import …Run Code Online (Sandbox Code Playgroud) 基本上,我一直在使用本指南:https://developers.google.com/drive/android/intro
我已经将图片上传到驱动器的帮助下:https://github.com/googledrive/android-demos/tree/master/src/com/google/android/gms/drive/sample/demo
但是,上面链接的GitHub项目没有提供从Drive中检索图像的任何方法,它只显示文本文件.我知道QueryNonTextFilesActivity.java,但这会在MetaDataBuffer中提供结果,并附加到ResultsAdapter上.我的问题是:我如何使用这些数据并转换为图像(.png)?
谢谢
android image download google-drive-api google-drive-android-api