Q:

upload file into google drive using java api

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);

using this code i upload file but that file is upload as a document.
     means i upload any type of that file is upload as a document in to google drive

A:

As far as I know (its been a few month since I looked) this is not (yet?) supported by the google drive API.
As a workaround consider installing the native google drive share and write the files you want to upload into the locally mapped shared folder. Then its google drives problem to handle the upload.

