Tag: 谷歌驱动 SDK

(Java)下载URL不起作用

我正在努力尝试使用谷歌驱动器API下载文件。 我只是编写应该从我的驱动器下载文件到我的计算机上的代码。 我终于到了一个我经过身份validation的阶段,可以查看文件元数据。 出于某种原因,我仍然无法下载文件。 我得到的downLoadURL看起来像: https://doc-04-as-docs.googleusercontent.com/docs/securesc/XXXXXXXXXXXXXX/0B4dSSlLzQCbOXzAxNGxuRUhVNEE?e=download&gd=true 当我运行代码或将其复制并粘贴到浏览器中时,此URl不会下载任何内容。 但是,在浏览器中,当我删除URL的“&gd = true”部分时,它会下载该文件。 我的下载方法直接来自google drive API文档: public static InputStream downloadFile(Drive service, File file) { if (file.getDownloadUrl() != null && file.getDownloadUrl().length() > 0) { try { System.out.println(“Downloading: “+ file.getTitle()); return service.files().get(file.getId()).executeMediaAsInputStream(); } catch (IOException e) { // An error occurred. e.printStackTrace(); return null; } } else { // The […]

Google云端硬盘未在文件夹中列出文件

当我提供文件夹ID时,Google云端硬盘不会列出文件夹中的文件,也不会在我提供mime类型时列出文件。 它适用于具有空查询的根文件夹中的文件。 如何列出文件夹中的文件? 码: public ArrayList getDriveList(String folder, String folderId) throws IOException { // Create a new authorized API client HttpTransport httpTransport = new NetHttpTransport(); JsonFactory jsonFactory = new JacksonFactory(); Credential credential = Utils.getCredential(); Drive service = new Drive.Builder(httpTransport, jsonFactory, credential) .setApplicationName(“SDM Mailer App”) .build(); ArrayList result = new ArrayList(); // String query = “”; […]

java,驱动APIv2,appengine 1.7.3,struts2.3.4.1,OAuth2。 TokenResponseException:400 OK invalid_grant

我收到错误invalid_grant我已经看过googleing arround,但是在这个问题已经有几天了。 错误被抛入: File file = insert.execute(); 我只是想从我的webapp上传文件到google驱动器。 我正在使用服务帐户在API Access(https://code.google.com/apis/console/)中生成的私钥对(.p12): Service account Use service accounts to call Google APIs on behalf of your application instead of an end-user. Learn more Client ID: xxx-xxxxxx.apps.googleusercontent.com Email address: xxx-xxxxxxxxxxx@developer.gserviceaccount.com Public key fingerprints: a108d8713103e09d0013655c9f80458f03e3a38a – Delete… 在Google APis – >驱动SDK(https://code.google.com/apis/console/?api=drive#project:347347146680:drive_sdk)中,我已将此ClientID放入: Drive Integration OAuth Client ID (Required) Enter the Client […]

drive.changes()。watch返回GoogleJsonResponseException:401未经授权而没有任何消息

我正在尝试关注Google云端硬盘的变化,并获得401例外。 在这里搜索,我发现人们有详细的信息,为什么他们没有未经授权,尽管我什么都没有。 这里我使用的代码: public static void main(String[] args) { try { httpTransport = GoogleNetHttpTransport.newTrustedTransport(); dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR); // authorization GoogleCredential credential = GoogleCredential.getApplicationDefault() .createScoped(DriveScopes.all()); boolean refreshed = credential.refreshToken(); // set up the global Drive instance drive = new Drive.Builder(httpTransport, JSON_FACTORY, credential) .setApplicationName(APPLICATION_NAME) .build(); Channel channel = new Channel(); channel.setId(UUID.randomUUID().toString()); channel.setType(“web_hook”); //my ip here channel.setAddress(“https://com.example:”); […]

解决方法:如何以编程方式编辑本机Google文档?

我在这里发现很少有相当抑郁的质量保证,其中提到谷歌文档无法在Google Drive API中以编程方式修改 – 只有上传/下载选项。 我查看了类似的主题: 1) 如何以编程方式操作本机谷歌文档文件 2) 如何以编程方式在Google Docs中创建文档? 因为我想我们无法直接下载和上传原生谷歌doc格式。 有没有其他方法可以解决这个问题? 有没有人试图以编程方式触发所选文档的谷歌应用程序脚本,这可能吗? 可以用输入上的一些参数以编程方式启动谷歌应用程序脚本吗? 我只需要在原生谷歌doc中替换几段文字,但我不能使用download-> modify-> upload(例如格式word / html / pdf)流程,因为我会破坏图片,边框等的格式… (客户要求:完全谷歌集成没有专有格式) 你有什么创新的想法或技巧可以探讨吗? 我们正在尝试将Google云端硬盘用作某种非常简单的模板系统(数千个用户,数百个谷歌文档),但这似乎是一个非常错误的想法,因为在途中存在很多限制。

无法再使用查询获取Google云端硬盘应用数据文件夹内容

出于某种原因,以下Android应用程序代码 com.google.api.services.drive.Drive drive; … drive.files().list().setQ(“mimeType=’application/vnd.google-apps.folder’ and ‘appdata’ in parents”).execute().getItems(); 从5月14日开始返回空列表。此代码返回我的自定义文件夹超过1年。 我可以看到我的App Data内容仍然存在 https://drive.google.com/drive/my-drive >设置>管理应用。 有什么想法有什么不对?

如何使用Android Google Spreadsheet API创建列表范围validation

我正在创建一个Android应用程序,在Google云端硬盘中创建一个新的电子表格并在其中插入一些数据。 目前我可以插入免费的文本和公式,但我需要添加一些特定的validation,特别是一个带有预定义值的下拉列表。 预期的结果应该是这样的: 我正在使用此代码: SpreadsheetFeed feed = spreadsheetService.getFeed( FeedURLFactory.getDefault() .getSpreadsheetsFeedUrl(), SpreadsheetFeed.class); // Creating the list of spreasheets in GDrive List spreadsheets = feed.getEntries(); // parsing trough the feed entries for (int i = 0; i < spreadsheets.size(); i++) { com.google.gdata.data.spreadsheet.SpreadsheetEntry e = (com.google.gdata.data.spreadsheet.SpreadsheetEntry) spreadsheets.get(i); // IF WE LOCATE THE FILE BASED ON THE FILENAME if( […]

使用Android将文本文件上传到Google云端硬盘

编辑:我已将文本设置为如下字符串: String text =(“Hello!”); 我想将其转换为纯文本文件,然后上传到Google云端硬盘文件夹。 我已经尝试过下面的代码,但它没有完整,所以我不能说出现了什么错误。 我正在使用谷歌硬盘“快速启动”演示,并尝试根据我的需要定制它。 链接: https : //github.com/googledrive/android-quickstart DriverClass: public class UploadDrive extends Activity implements ConnectionCallbacks,OnConnectionFailedListener { private static final String TAG = “androiddrivequickstart”; private static final int REQUEST_CODE_CAPTURE_IMAGE = 1; private static final int REQUEST_CODE_CREATOR = 2; private static final int REQUEST_CODE_RESOLUTION = 3; private GoogleApiClient mGoogleApiClient; private Bitmap mBitmapToSave; private […]

com.google.api.client.auth.oauth2.TokenResponseException:401未经授权

我想使用Java Google Drive API。 我试过这段代码: public Drive getDriveService() throws GeneralSecurityException, IOException, URISyntaxException { HttpTransport httpTransport = new NetHttpTransport(); JacksonFactory JSON_FACTORY = new JacksonFactory(); GoogleCredential credential = new GoogleCredential.Builder() .setTransport(httpTransport) .setJsonFactory(JSON_FACTORY) .setServiceAccountId(“sonoratestw-226@sonora-project.iam.gserviceaccount.com”) .setServiceAccountPrivateKeyFromP12File(new java.io.File(“C:\\buffer\\sonora project-3256770463ed.p12”)) .setServiceAccountScopes(Collections.singleton(SQLAdminScopes.SQLSERVICE_ADMIN)) .setServiceAccountUser(“sonoratestw@gmail.com”) .build(); Drive service = new Drive.Builder(httpTransport, JSON_FACTORY, null) .setApplicationName(“FileListAccessProject”) .setHttpRequestInitializer(credential).build(); return service; } 但我得到这个错误: An error occurred: com.google.api.client.auth.oauth2.TokenResponseException: 401 […]

如何在Google Drive SDK java客户端中为Insertfunction指定uploadType

在插入function的Google Drive SDK中, 文档说需要uploadType参数,并且可以使用3个值。 但它没有指定在使用Java客户端时如何定义此值。 目前尚不清楚该示例是使用简单,多部分还是可恢复的。 如何在java api中定义uploadType。 谢谢