Unable to access certain Google Drive folders using Zend GData libraries although folder is listed in My Drive

678 views Asked by At

I'm querying Google Drive and passing in a folder name if which I want to list the folders/file contained with in it. My code works, I can view content of some folders, but for certain folders that are visible within the Google Drive web UI, I don't get any entries returned, but there is content.

I'm using Zend_Gdata_Docs and Zend_Gdata_Docs_DocumentListFeed is doing the heavy lifting, but the _entry array which should contain the folder contents is empty when it should contain an array of Zend_Gdata_Docs_DocumentListEntry objects.

I'm passing the folder by appending the folder name to https://docs.google.com/feeds/documents/private/full/-/some-folder-name

Whats proving to me it a Google issue is if I rename the folder causing issues and create a new folder with the same name my code works and I see the contents.

All very strange any pointers before I ditch Google Drive and move to Dropbox?

2

There are 2 answers

0
Jon Mears On BEST ANSWER

Looks like the issues was with the visibility of the files and folders in Google Drive. As said before the code is good all things pointed to something up with Google Drive.

To make the files and folders visible again I did the following;

  1. From within drive.google.com select the the files/folders in question
  2. From the 'More' button choose 'Share'
  3. Change the 'Who has Access' settings, click 'Save' then 'Done'
  4. Revert 'Who has Access' to previous setting if required.

So the visibility on certain folders is being lost or corrupted somehow.

UPDATE

I wrote a Google Apps Script that updates the permissions of the sub folders and call it from my web app. The script need to created as Web App and deployed for use. THe script is called via regular script src (as XHR isn't allowed with Google Apps Scripts)

function doGet(request) {

  var folders = DriveApp.getRootFolder().getFoldersByName(request.parameters.folder);

  while (folders.hasNext()) {
    var folder = folders.next();
    var subFolders = folder.getFolders();

    while (subFolders.hasNext()) {
      var subFolder = subFolders.next();

      subFolder.setSharing(DriveApp.Access.DOMAIN_WITH_LINK, DriveApp.Permission.VIEW );

    }
  }

  var result = '';

  return ContentService.createTextOutput(result).setMimeType(ContentService.MimeType.JAVASCRIPT);

}

Hope this is of some help to someone.

1
Zig Mandel On

You need to pass the folder id not the name