Drive API知道何时将文件发送到垃圾箱

时间:2017-08-01 10:22:41

标签: google-drive-api drive

我试图知道某个文件何时被发送到驱动器垃圾箱。我尝试了以下但似乎没有任何作用:

@POST
@Path("/webhook")
public void webhook(@Context HttpServletRequest request, @Context HttpServletResponse response) throws IOException {
    Credential credential = initFlow().loadCredential("user");
    Drive service = new Drive.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential).setApplicationName(APPLICATION_NAME).build();

    String pageToken = GDrive.savedPageToken;
    Logger log = Logger.getLogger("thread");
    log.setLevel(Level.INFO);

    while (pageToken != null) {
        ChangeList changes = service.changes().list(pageToken).execute();

        for (Change change : changes.getChanges()) {

            if  ( change.getFile() == null ) {
                log.info("IGNORE: "+change.getFileId());

            }
            else if (!change.getFile().getMimeType().equalsIgnoreCase("application/vnd.google-apps.folder")) {
                log.info("TRASHED REMOVE DIGITAL INPUT: "+change.getFile().getTrashed());
                log.info("TRASHED REMOVE DIGITAL INPUT: "+change.getRemoved());
                log.info("TRASHED REMOVE DIGITAL INPUT: "+change.getFile().getExplicitlyTrashed());
                log.info("TRASHED REMOVE DIGITAL INPUT: "+change.getFile().getName());
            }
        }
        if (changes.getNewStartPageToken() != null) {
            GDrive.savedPageToken = changes.getNewStartPageToken();
        }
        pageToken = changes.getNextPageToken();
    }
    response.setStatus(200);
}

第一个限制change.getFile() == null用于何时从驱动器中完全删除文件。

在第二个问题上,我尝试查看何时将文件发送到垃圾箱,但这些功能getTrashed()getRemoved()getExplicityTrashed()始终为空或假。

我怎么知道何时删除文件?

0 个答案:

没有答案