You need to authenticate your cordova app with Google in order to use the API. First, follow the official Google guidelines for each platform (iOS and Android), if you haven’t already, to create the necessary credentials for your application. Then try the plugin from the link below:
Google Plugin for Google Cordoba Plugin
I created this plugin for a personal mobile project. This plugin supports upload, download and file list.
To get a list of files created / uploaded by your Android application, you can try this on the 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();
source share