更新谷歌驱动器中的文件

时间:2016-03-24 12:02:35

标签: java google-drive-api

我想在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();

0 个答案:

没有答案