Google-drive – Advanced Google Drive search — locating the file

google-drivegoogle-drive-search

I have discovered that there is an app option that I can filter you out specific mime type files, like https://drive.google.com/drive/search?q=app:"your app name". But what if I want only specific file? I have its id (id is called selfLink when I fetch it programmatically with gapi.client.drive.files.list). How do I select right that file in a new Google Drive page?

I see that in Google Drive web interface there is "More Actions > Locate" menu. But, it selects me the file without disclosing the secret in the URL address how did it that jump.

I also see that I can https://drive.google.com/open?id=<file id> to open any file, as open keyword suggest in the URL string. Is there another action just to locate the file in the web interface, instead of opening it?

Best Answer

The best solution I reached so far is to use https://drive.google.com/open?id=' + file.id.

This will open a file open window, where, if app open fails, as it is in mine case, you can rename the file or open the details. The details window allows you to locate the file in the google drive. I just wonder if it is possible to do directly, without open action, which fortunately fails in my case.

There is some dubious site which seems to publish the code to generate the goodle doc preview URL

  public static String outputFileAsIFrameGetURL(File fileToOutput) { 

    String domain = fileToOutput.getOwners().get(0).getEmailAddress().split("@")[1]; 
    String id = fileToOutput.getId(); 

    switch (fileToOutput.getMimeType()) { 
      case Mime.DOCUMENT: 
        return "https://docs.google.com/a/" + domain + "/document/d/" + id + "/preview"; 
      case Mime.SPREADSHEET: 
        return "https://docs.google.com/a/" + domain + "/spreadsheet/ccc?key=" + id + "&output=html&widget=true&chrome=false"; 
      case Mime.PRESENTATION: 
        return "https://docs.google.com/a/" + domain + "/presentation/d/" + id + "/preview"; 
      case Mime.DRAWING: 
        return "https://docs.google.com/a/" + domain + "/drawings/d/" + id + "/preview"; 
      default: 
        return "https://docs.google.com/a/" + domain + "/file/d/" + id + "/preview"; 
    } 

which says that I need file/d/ prefix to preview my document. But I am not sure how much can I rely on it.