Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find file's parent id : Google Drive API V3

enter image description here

Today after I updated my Drive API to V3, I dint find any method to find the parent of the selected file . Is the rest endpoint to fetch json related to parent's info changed?

like image 365
akgaur Avatar asked Dec 14 '15 09:12

akgaur


People also ask

How do I find my Google Drive API folder ID?

Getting this folder ID is easy, navigate to https://drive.google.com and make a folder. After you did this, open up the folder and check the URL: Grab this ID and enter it inside the 'Folder ID's' inside the modal to specify that the backup has to be put in that folder.

How do I see parent folder in Google Drive?

You'd need to grab the title of the doc and search for it in your Drive list view. The search results should show you the document title, then also show the name of the parent folder in gray. A round about way but it's a solution. Thanks!

How do I find the owner of a Google Drive link?

If the file is Public on the web or accessible via a link, yes, you can. The same applies to being directly shared with you via email, except there are no extra steps, just press "Share" and you'll see the editors and owners.


1 Answers

If you have the file id of the file in question then Files: get you need to add fields ie parents along with the file id.

Request

GET https://www.googleapis.com/drive/v3/files/0B5pJkOVaKccENWNNcFFaU2lSM0E?fields=parents&key={YOUR_API_KEY}

Returns

{ "parents": [ "0B5pJkOVaKccEYW5lVHBKd1Zwc28" ] }

The result is actually a file id. Remember files and directories are the same in Drive.

Do files.get again

GET https://www.googleapis.com/drive/v3/files/0B5pJkOVaKccEYW5lVHBKd1Zwc28?key={YOUR_API_KEY}

Results

{ "kind": "drive#file", "id": "0B5pJkOVaKccEYW5lVHBKd1Zwc28", "name": "SiteBackups", "mimeType": "application/vnd.google-apps.folder" }

like image 102
DaImTo Avatar answered Sep 19 '22 20:09

DaImTo