本文介绍了如何在离子应用程序中实现谷歌驱动器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将我的 ionic 应用程序连接到谷歌驱动器,显示所有文件,并且可能上传、下载、删除、编辑.所以我试试这个https://github.com/Raza-Dar/ionic-google-drive2

i need to connect my ionic app to google drive, show all the files, and maybe upload, download,delete, edit.So I try thishttps://github.com/Raza-Dar/ionic-google-drive2

错误:加载资源失败:服务器响应状态为 404(未找到)https://apis.google.com//scs/apps-static//js/k=oz.gapi.en.RArmLpCIYB0.O/m…1/ed=1/am=QQ/rs=AGLTcCOEiG2RgKkKDvOG7y5PZ-fMFMsJXQ/t=zcms/cb=gapi.loaded_01

errors:Failed to load resource: the server responded with a status of 404 (Not Found) https://apis.google.com//scs/apps-static//js/k=oz.gapi.en.RArmLpCIYB0.O/m…1/ed=1/am=QQ/rs=AGLTcCOEiG2RgKkKDvOG7y5PZ-fMFMsJXQ/t=zcms/cb=gapi.loaded_01

未捕获的类型错误:无法调用未定义的方法load"

Uncaught TypeError: Cannot call method 'load' of undefined

找不到 InAppBrowser 插件

Could not find InAppBrowser plugin

还有这个http://blog.ionic.io/oauth-ionic-ngcordova/1控制台上没有错误...但在身份验证后返回主页

and thishttp://blog.ionic.io/oauth-ionic-ngcordova/1no errors on console...but after authentication return to the main page

还有这个http://excellencenodejsblog.com/cordova-ionic-google-oauth-login-for-your-mobile-app/有了这个,我得到了用户的信息,但不是驱动器中的文件

and thishttp://excellencenodejsblog.com/cordova-ionic-google-oauth-login-for-your-mobile-app/with this i get the info of the users but not the file in drive

有什么建议吗?请我需要一些有效的示例入门代码谢谢

any suggestion?Please i need some working example starter codeThank you

推荐答案

您需要通过 Google 对您的cordova 应用程序进行本地身份验证,以便使用这些 API.如果您还没有,请首先按照每个平台(iOS 和 Android)的官方 Google 指南为您的应用程序创建所需的凭据.然后尝试以下链接上的插件:

You need to authenticate natively your cordova application with Google in order to make use of the APIs. Firstly follow the official Google guides for each platform (iOS and Android) if you haven't already, to create the required credentials for your application. Then try the plugin on the link below:

Cordova 谷歌驱动插件

我为个人移动项目创建了这个插件.该插件支持上传、下载和文件列表.

I created this plugin for a personal mobile project. This plugin supports upload,download and list of files.

要检索由您的 Android 应用程序创建/上传的文件列表,您可以在 Java 端尝试此操作:

To retrieve a list of files created/uploaded by your application for Android you can try this on Java side:

private void fileList() {
    Query query = new Query.Builder().addFilter(Filters.and(
            Filters.eq(SearchableField.MIME_TYPE, "application/octet-stream"),
            Filters.eq(SearchableField.TRASHED, false))).build();

    Drive.DriveApi.query(mGoogleApiClient, query)
            .setResultCallback(new ResultCallback<DriveApi.MetadataBufferResult>() {
                @Override
                public void onResult(DriveApi.MetadataBufferResult result) {
                    if (!result.getStatus().isSuccess()) {
                        mCallbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR,"failed to retrieve file list"));
                        return;
                    }
                    MetadataBuffer flist = result.getMetadataBuffer();
                    Log.i(TAG,flist.get(0).getClass().getName());
                    JSONArray response = new JSONArray();
                    for (Metadata file: flist
                         ) {
                        try {
                            response.put(new JSONObject().put("name", file.getTitle()).put("created", file.getCreatedDate().toString()).put("id", file.getDriveId().toString()));
                        }catch (JSONException ex){ex.getMessage();}
                    }
                    JSONObject flistJSON = new JSONObject();
                    try{
                        flistJSON.put("flist", response);
                    } catch (JSONException ex){}
                    mCallbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK,flistJSON));
                    flist.release();
                    //Log.i(TAG,flist.toString());
                }
            });
}

这篇关于如何在离子应用程序中实现谷歌驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 01:15