繁体   English   中英

在Google App Engine中访问Google云端硬盘文件[共享链接]

[英]Accessing Google Drive Files in Google App Engine [Shareable Link]

我有一个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引擎发布到另一台服务器。 如何从Google App Engine [python]或android获取共享链接?

要么

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

在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编辑器或查看器中打开文件

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM