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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With