I am using google drive V3 REST api to upload a multipart file from a POST request & below is the java code
String accessToken = "xyz";
Credential credential = new GoogleCredential().setAccessToken(accessToken);
Drive service = new Drive.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
.setApplicationName("xyz")
.build();
File fileMeta = new File();
fileMeta.setName(fileName);
fileMeta.setMimeType("application/vnd.google-apps.file");
if (!parentFolderId.isEmpty()) {
fileMeta.setParents(Collections.singletonList(parentFolderId));
}
//Code to upload file in GDrive
java.io.File tmpFile = java.io.File.createTempFile("uploadFile", ".tmp");
//Writing the file content to the new file
InputStream in = multipartFile.getInputStream();
FileOutputStream fos = new FileOutputStream(tmpFile);
IOUtils.copy(in, fos);
in.close();
fos.close();
tmpFile.deleteOnExit();
FileContent mediaContent = new FileContent(null, tmpFile);
File file = service.files().create(fileMeta, mediaContent)
.setFields("id")
.execute();
Upload is working fine but all the uploads are getting auto-converted into documents which I do not want. I see from the question Google Drive: Automatically convert files on upload? that convert=true needs to be set during insert. But this option is not available in V3.
Can someone tell me how do i disable this auto-conversion during uploads ?