Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the link of a publicly shared file/folder

we can share a file/folder using https://developers.google.com/drive/v2/reference/permissions/insert . But the response ( https://developers.google.com/drive/v2/reference/permissions#resource ) won't contain the link to share the file/folder.

After sharing a file/folder, you can get the link to share the file/folder using https://developers.google.com/drive/v2/reference/files/get. So we need to send one more request to get the link. It will be useful if we get the link in the first request itself.

I just played with Google drive web interface and got the pattern of the link to share a file/folder as given below:

For files: https://docs.google.com/file/d/{file-id}/edit

For folders: https://docs.google.com/folder/d/{folder-id}/edit

It is working fine now.

Is it correct to get the shared file/folder? will it break in future?

like image 763
Mohammed H Avatar asked Nov 03 '22 06:11

Mohammed H


1 Answers

The alternateLink of the File resource from drive.files.* methods should contain the link to view the file in Google Drive. This will be consistent, and the best way of finding the correct URL.

Having said that, likely those URLs that you engineered will not change, but best to be safe.

like image 80
Ali Afshar Avatar answered Nov 16 '22 19:11

Ali Afshar