DocsService client = new DocsService("service name");
client.setUserCredentials(username,password);
File file = new File(filename);
URL url = new URL("https://docs.google.com/feeds/default/private/full/?ocr=true&convert=true");
String mimeType = DocumentListEntry.MediaType.fromFileName(file.getName()).getMimeType();
DocumentEntry newDocument = new DocumentEntry();
newDocument.setTitle(new PlainTextConstruct(file.getName()));
newDocument.setMediaSource(new MediaFileSource(file, mimeType));
//newDocument.setFile(file, mimeType);
newDocument = client.insert(url, newDocument);
System.out.println("uploaded "+file.getName());
JOptionPane.showMessageDialog(null, "uploaded "+file.getName(), "alert", JOptionPane.ERROR_MESSAGE);
使用此代码我上传文件,但该文件上传为文档。 意味着我上传任何类型的文件被上传的文档中的谷歌驱动使用java api上传文件到谷歌驱动器
hello @Shersha Fn我是这个云端事物的初学者,我想从头开始编写一个java代码,以提供一个按钮,将文件上传到我的谷歌帐号!我怎样才能做到这一点 ?我没有得到任何线索,文件正在我的头上 – minigeek 2017-02-13 10:01:07