Van Coding
Van Coding

Reputation: 24554

Google Document List API - Get Collection or Item by its path?

I'm currently developing a google drive client. This documentation describes how to access collections or items by their ID. But how is it possible to get an item by its path?

For example, I want to get a file /documents/pictures/sunshine.png. How can I get this file withouth knowing its ID?

Upvotes: 5

Views: 1349

Answers (4)

user2458584
user2458584

Reputation: 1

You can get the Document ID by looking at the URL. For example, if I have a document open in the browser and the URL is:

https://docs.google.com/a/apps.kingsacademy.edu.jo/document/d/1tb6oqih33k1BhadraHNdozizAB7kok-8WRHo_35xeVA/edit

Then the Document ID is: 1tb6oqih33k1BhadraHNdozizAB7kok-8WRHo_35xeVA

Upvotes: 0

Alexander
Alexander

Reputation: 261

you can use the google docs api , and search by the title parameter , if you have some documents made with some application in drive this will be returned the document, i think you have to add the scope https://www.googleapis.com/auth/drive.file to get the authorization.

Upvotes: 0

user1335794
user1335794

Reputation: 1092

Alian, I have the same feeling with Van Coding. I my application I just use google doc as a document database.

I do not want to expose google doc UI to my customer. If user want to edit a file, what I did is download that file with html format and display it in a html editor.

I most time I just know a file name (beacuse it is more sensitive for a user than a resouceID) and need find this file in google doc. So if I could access a file via a path would be much convenience.

Upvotes: 2

Alain
Alain

Reputation: 6034

With the current version of the API, it is not possible to directly access a file by filename. This limitation is due to the fact that a user can have multiple files having the same name in the same folder.

The only way to get access to a file is by its ID. The path is not necessary as the file's metadata contains parentsFolder information.

Upvotes: 1

Related Questions