简体   繁体   English

如何使用Java-Google Docs Api将文件上传到Google驱动器?

[英]How to upload files to google drive using java-Google Docs Api?

Already I used older version of the API to upload files to Google docs but now the API version is revised, so I couldn't upload. 我已经使用API​​的较早版本将文件上传到Google文档,但是现在API版本已修改,因此我无法上传。

Previously I used these lines for authorization: 以前,我使用以下行进行授权:

DocsService service = new DocsService("MyDocumentsListIntegration-v1");
    service.setUserCredentials(USERNAME, PASSWORD);

But now it is giving this error: 但是现在它给出了这个错误:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException
    at sample.main(sample.java:15)
Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 1 more

Can anyone help me? 谁能帮我?

It seems like you are missing one of the external dependencies, mail.jar, which is part of Sun's JavaMail API. 似乎您缺少外部依赖项之一mail.jar,它是Sun的JavaMail API的一部分。

Check this page for instructions on how to get it as well as all other external dependencies: https://developers.google.com/gdata/articles/java_client_lib 检查此页面以获取有关如何获取它以及所有其他外部依赖项的说明: https : //developers.google.com/gdata/articles/java_client_lib

Check this link for a migration guide for the old GData api: http://code.google.com/p/gdata-java-client/wiki/MigratingToGoogleApiJavaClient 检查此链接以获取旧GData API的迁移指南: http : //code.google.com/p/gdata-java-client/wiki/MigratingToGoogleApiJavaClient

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用java api将文件上传到谷歌驱动器 - upload file into google drive using java api 如何使用Java API在Google驱动器中上传Excel工作表 - how to upload an excel sheet in google drive using java api 如何使用 Java Google Drive API 上传文件 - How to upload file using Java Google Drive API 使用 google docs api (java) 创建 Google 文档 - Create Google docs using google docs api (java) 使用 Java 和 Google Drive API V3 将文件上传到共享的 Google Drive 位置? - Upload a file to shared google drive location using Java with Google Drive API V3? Google Drive Android API如何将音频文件上传到我的驱动器? 如何同步驱动器文件? - Google Drive Android API how to upload a audio file to my drive ? How to sync drive files? 将Google Drive API与Jav​​a配合使用,如何仅列出驱动器部分/文件夹中的文件 - Using Google Drive API with Java, how to list only files in the Drive Section/Folder 使用Java中的Google Drive SDK API显示文件列表 - Display the list of files using Google Drive SDK API in Java 如何使用drive api java从谷歌驱动器下载文件? - How to download a file from google drive using drive api java? 如何使用Java和Drive API在Google Drive上创建电子表格 - How to create a Spread Sheet on Google Drive Using Java and Drive API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM