从App Engine应用程序将文件上传到Google云端硬盘

时间:2018-12-14 17:37:25

标签: java jsp google-app-engine servlets google-drive-api

我正在尝试实施应将文件从用户计算机上传到Team Drive文件夹的App Engine应用程序。 目前,我正在尝试使用.jsp和servlet进行此操作,但似乎无法做到这一点。 我正在使用Java的服务帐户和Drive API客户端库-https://developers.google.com/api-client-library/java/apis/drive/v3 看来,以这种方式上传文件时,您应该使用java.io.File,这在App Engine上是不可能的,因为文件不是存储在实例上,而是从用户计算机上上传的。

可以使用App Engine将文件直接上传到Google云端硬盘吗?

附加说明:
我正在使用Drive API v3。
在Drive API v2中,有可用的file.insert()方法,该方法使您可以将InputStream发送为输入参数。我认为这种方法可以帮助我进行上传,但API v3中未包含该方法。 https://developers.google.com/drive/api/v2/reference/files/insert

1 个答案:

答案 0 :(得分:0)

我认为您正在从https://developers.google.com/resources/api-libraries/documentation/drive/v3/java/latest/中寻找protected Create(File content, com.google.api.client.http.AbstractInputStreamContent mediaContent)