0
我使用谷歌驅動V3 REST API從POST請求低於&上傳多文件是Java代碼谷歌驅動文件上傳得到轉換爲DOC
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();
上傳工作正常,但所有上傳內容自動轉換成我不想要的文檔。我從問題Google Drive: Automatically convert files on upload?看到convert = true需要在插入期間設置。但是這個選項在V3中不可用。
有人能告訴我如何禁用上傳過程中的自動轉換?