【问题标题】:Accessing Google Drive Files in Google App Engine [Shareable Link]在 Google App Engine 中访问 Google Drive 文件 [共享链接]
【发布时间】:2016-10-04 01:26:36
【问题描述】:

我有一个 android 应用程序,它可以将图像保存到 Google 云端硬盘中,并将网络链接共享到我的 Google App Engine 服务器 (python)。

    // Create client
    mGoogleApiClient = new GoogleApiClient.Builder(mContext)
        .addApi(Drive.API)
        .addScope(Drive.SCOPE_FILE)
        .addConnectionCallbacks(this)
        .addOnConnectionFailedListener(this)
        .build();

   // handling results after uploading
   final DriveOperationResult<Metadata> driveOperationResultHandler = new DriveOperationResult<Metadata>() {

    @Override
    public void onDriveOperationSucceeded(Metadata result) {
        try {
            // Successfully fetched metadata
            onSuccess(driveId,
                      result.getOriginalFilename(),
                      result.getWebContentLink(),
                      result.getWebViewLink(),
                      result.getAlternateLink(),
                      result.getEmbedLink());
        } finally {
            mGoogleDriveClient.disconnectAsync();
        }
    }

注意: result.getEmbedLink() 总是返回 null。此外,result.getAlternateLink() 和 result.getWebContentLink() 不可访问。我正在使用 Google Drive Android API。

我需要从谷歌应用引擎发布到另一台服务器的链接。如何从 google app engine [python] 或 android 获取可共享链接?

如何更改链接的权限,以便知道链接的任何人都可以阅读?

【问题讨论】:

  • 向我们展示您在尝试了 appengine 中的 Drive api(使用您的 appengine 语言的库或使用 Rest)之后到目前为止所尝试的内容,以及失败的原因。还要说明是您的驱动器还是用户驱动器。

标签: android python google-app-engine google-drive-api file-sharing


【解决方案1】:

在python中,你必须这样做

@decorator.oauth_required
def get(self):
    try:
        http = decorator.http()
        service = discovery.build("drive", "v2", http=http)

        # Make the list of every files in the user's Drive
        # Take every fields we will need after
        fields = "items(id,title,,alternateLink)
        list = service.files().list(fields=fields).execute()

然后使用alternateLink 属性获取可以共享的链接,以便在相关的Google 编辑器或查看器中打开文件

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-19
    相关资源
    最近更新 更多