Search code examples
javagoogle-docsgdata

Get a FileEntry from a path in Google Documents List Api (gdata-java-client)


How do I get a Google Docs FileEntry from its path?

Once I get the paths from entries in Google Docs, such as:

https://doc-04-20-docs.googleusercontent.com/docs/secure/m71240U1?h=1630126&e=download&gd=true

How do I obtain their corresponding FileEntries later?


Solution

  • Call the getEntry method on an authenticated DocsService.

    String rootUrl = "https://docs.google.com/feeds/default/private/full";
    String path = //file entry's id
    FileEntry entry = _service.getEntry(new URL(rootUrl + "/" + URLEncoder.encode(path, "UTF-8")), FileEntry.class);