簡體   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