2

我正在开发的 Android 应用程序与 Google Drive 集成。我有一个在驱动器上复制文件的功能,我使用以下代码:

        File newFile = new File();
        newFile.setTitle(mItem.GetName());
        ParentReference newParent = new ParentReference();
        newParent.setId(gDriveFolder.getFileId());
        List<ParentReference> parents = new ArrayList<ParentReference>(1);
        parents.add(newParent);
        newFile.setParents(parents);
        File copiedFile = service.files().copy(mItem.getFileId(), newFile).execute();   
        String copiedFileId = copiedFile.getId();

        long copiedModDate = copiedFile.getModifiedDate().getValue();       
        Log.d("serverSideCopyMove", "File returned from copy command has modified date of " + copiedModDate);

        // bug here in google drive because the last mod date returned from the above 
        // gets changed a few micro-seconds later, thus the need to make a separate
        // server call to get new mod date again
        File getFile = service.files().get(copiedFileId).execute();
        copiedModDate = getFile.getModifiedDate().getValue(); //why different value?
        Log.d("serverSideCopyMove", "Separate call to get same copied file returns modified date of " + copiedModDate);
        // end of workaround

您将从我的代码中看到,从复制命令返回的文件的修改日期与我对同一文件执行“获取”时不同。我只是想知道这是一个错误还是我错误地使用了调用?

4

0 回答 0