我想在google驱动器文件夹中创建电子表格文件,如果它已存在于目录中以进行更新。新文件创建工作正常,但我无法更新现有文件。我做错了什么?
Exception in thread "main" java.lang.IllegalArgumentException
at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkArgument(Preconditions.java:76)
at com.google.api.client.util.Preconditions.checkArgument(Preconditions.java:37)
at com.google.api.client.googleapis.media.MediaHttpUploader.setInitiationRequestMethod(MediaHttpUploader.java:872)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.initializeMediaUpload(AbstractGoogleClientRequest.java:237)
at com.google.api.services.drive.Drive$Files$Update.<init>(Drive.java:3155)
at com.google.api.services.drive.Drive$Files.update(Drive.java:3105)
at DriveQuickstart$2.visitFile(DriveQuickstart.java:248)
我的代码:
Drive.Files.Update u = service.files().update(id, new File(), new FileContent("text/csv", path.toFile()));
File f = u.execute();