且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Google Drive Rest API v3-如何将文件移至回收站?

更新时间:2022-04-02 22:09:08

我看不到您的代码有关如何将文件移至

I don't see any error with your code on how to move a file to trash wherein you'll use files.update with {'trashed':true}.

线程中的代码示例:

解决方案是创建一个空的File设置,仅设置新值:

The solution is to create an empty File setting only the new values:

File newContent = new File();
newContent.setTrashed(true);
service.files().update(fileId, newContent).execute();

我已经在Google云端硬盘中尝试过此操作尝试一下!并将文件成功移至回收站.

I have tried this in Google Drive Try it! and successfully moved the file to trash.

只需确保File引用com.google.api.services.drive.model.File,并且不是 java.io.File.

Just make sure that the File refers to com.google.api.services.drive.model.File and it is not java.io.File.