简体   繁体   English

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

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

I have an android app that saves an image into the Google Drive and shares the weblink to my Google App Engine server (python). 我有一个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();
        }
    }

Note: result.getEmbedLink() always returns null. 注意: result.getEmbedLink()始终返回null。 Also, result.getAlternateLink() and result.getWebContentLink() are not accessible. 另外,result.getAlternateLink()和result.getWebContentLink()不可访问。 I am using Google Drive Android API. 我正在使用Google Drive Android API。

I need to post the link to another server from the google app engine. 我需要将链接从Google App引擎发布到另一台服务器。 How do I get a shareable link from google app engine [python] or android? 如何从Google App Engine [python]或android获取共享链接?

or 要么

How do I change the permission on the link so that anyone with the link can read? 如何更改链接的权限,以便具有链接的任何人都可以阅读?

In python, you must do something like this 在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()

Then use the alternateLink property to get a link that can be shared for opening the file in the relevant Google editor or viewer 然后,使用alternateLink属性获取可以共享的链接,以在相关的Google编辑器或查看器中打开文件

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

相关问题 获取上传文件的可共享链接到Android中的Google驱动器 - Get Shareable link of uploaded file to google drive in android 访问与具有链接的任何人共享的Google驱动器目录中的文件可以查看 - accessing files in a google drive directory that is shared with anyone with link can view 是否可以在 android 应用程序中使用 Google 驱动器共享数据? - Is it possible to use Google drive for shareable data in android apps? Servlet无法访问Google App Engine API - Servlet not accessing google app engine api 我正在尝试使用视频视图中的共享链接来播放Google驱动器中的视频,但无法播放此解决方案? - I am trying to play video from google drive using shareable link in video view but unable to play what is the solution for this? 在Android中访问Google驱动器 - Accessing google drive in android 链接到本地​​Google App Engine数据库 - Link to local Google App Engine database 将领域文件存储在Google云端硬盘应用文件夹中? - Store Realm files in Google Drive App Folder? 用于读取 Google Drive 中写入文件的 Android 应用程序 - Android App to read write files in Google Drive 在我的Android应用中管理Google云端硬盘上的文件 - Managing files on Google Drive in my Android app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM