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