0

我需要使用 Google Drive Api for Java 将文档的内容复制到另一个文档中,两者都存储在谷歌驱动器中。我可以上传或下载文档,但我不知道如何将文档的内容直接传输到另一个文档中。我想到了这样的事情:

public void copyContent(String sourceId, String destinationId) {
   File sourceFile = service.files().get(sourceId).execute();
   AbstractInputStreamContent content = null; //sourceFile.getContent()??? :-(

   File destinationFile = service.files().get(destinationId).execute();
   service.files().update(destinationId, destinationFile, content).execute();
}

有办法将文件内容作为 AbstractInputStreamContent 获取吗?或者它是否存在另一种复制内容的方法?我需要一个无需导出/上传文档的解决方案,因为我注意到了一些转换问题。谢谢!

4

1 回答 1

0

您可以使用files.copyDrive API 的方法来创建现有文档的副本:

https://developers.google.com/drive/v2/reference/files/copy

于 2012-10-18T16:11:29.227 回答