I am working on an ứng dụng using Google Drive. I want the user to lớn be able to nội dung files by link, setting the permissions lớn anyone & withLink as described in the Google Developers documentation.

Bạn đang xem: Simple url tricks for google drive you should know

However, I cannot figure out what links to share. When I share a tệp tin in the Google Drive browser interface, I see the link to giới thiệu in the format:

https://docs.google.com/presentation/d/<...>/edit?usp=sharing

A liên kết in this format is not part of the file resource object, nor it is returned from the http hotline setting the permissions. I hope someone can explain lớn me how to lớn get this liên kết through the REST api?


google-drive-api
nội dung
Improve this question
Follow
edited Oct 30, năm trước at 14:21
*

Jawa
2,32866 gold badges3434 silver badges3939 bronze badges
asked Mar 4, 2013 at 12:58
*

Jon SaalbachJon Saalbach
35511 gold badge44 silver badges77 bronze badges
địa chỉ cửa hàng a phản hồi |

4 Answers 4


Sorted by: Reset to default
Highest score (default) Date modified (newest first) Date created (oldest first)
25
You can use the alternateLink property in the file resource khổng lồ get a link that can be shared for opening the file in the relevant Google editor or viewer:

https://developers.google.com/drive/v2/reference/files

Update

(https://developers.google.com/drive/api/v3/reference/files it is suggested to lớn use the webViewLink property.


mô tả
Improve this answer
Follow
edited Sep 10, 2019 at 10:08
*

wpp
6,72733 gold badges3232 silver badges6363 bronze badges
answered Mar 5, 2013 at 5:53
*

Claudio CherubinoClaudio Cherubino
14.7k11 gold badge3333 silver badges4040 bronze badges
4
địa chỉ a bình luận |
15
To actually enable liên kết sharing using Google Drive API:

drive.permissions.create( fileId: "......", requestBody: role: "reader", type: "anyone", );Get the webLinkView value using:

const webViewLink = await drive.files.get( fileId: file.id, fields: "webViewLink").then(response => response.data.webViewLink);
share
Improve this answer
Follow
answered Feb 26, 2019 at 20:31

*

rzymekrzymek
8,62422 gold badges4343 silver badges5555 bronze badges
1
địa chỉ cửa hàng a bình luận |
3
In my case using the PHP Api v3, for the links to be non-empty you must define that you request this field... & if you have the right permissions:

so something lượt thích this:

$file =self::$service->files->get("1ogXyGxcJdMXt7nJddTpVqwd6_G8Hd5sUfq4b4cxvotest",array("fields"=>"webViewLink"));
nội dung
Improve this answer
Follow
answered Feb 23, 2017 at 13:50
MiguelMiguel
2,88322 gold badges2929 silver badges2727 bronze badges
2
showroom a comment |
1
Here"s a practical example on how lớn get the WebViewLink file property (A.K.A. File edit link):

$file = $service->files->get($file_id, array("fields" => "webViewLink"));$web_link_view = $file->getWebViewLink();OR

$sheetsList = $drive_service->files->listFiles(< "fields" => "files(id, name, webViewLink, webContentLink)",>);$web_link_view = $sheetsList->current()->getWebViewLink();Pay attention that you should load the tệp tin specifying which fields you wanna bring with it (In this case, webViewLink). If you don"t vị that, only id và name will be available.

Xem thêm: Messenger Bị Chặn Gửi Tin Nhắn Facebook Bao Lâu? Cách Không Nhận Tin Nhắn Người Lạ Trên Messenger

In case you need lớn adjust the tệp tin sharing settings, this is how you bởi it:

$permissions = new Google_Service_Drive_Permission();$permissions->setRole("writer");$permissions->setType("anyone");$drive_service->permissions->create($file_id, $permissions);Possible values for setRole() và setType() can be found here: https://developers.google.com/drive/api/v3/reference/permissions/create


cốt truyện
Improve this answer
Follow
answered Aug 7, 2020 at 15:02
Heitor AlthmannHeitor Althmann
13711 silver badge44 bronze badges
địa chỉ cửa hàng a comment |

Your Answer


Thanks for contributing an answer lớn Stack Overflow!

Please be sure khổng lồ answer the question. Provide details và share your research!

But avoid

Asking for help, clarification, or responding khổng lồ other answers.Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.


Draft saved
Draft discarded

Sign up or log in


Sign up using Google
Sign up using Facebook
Sign up using thư điện tử and Password
Submit

Post as a guest


Name
email Required, but never shown


Post as a guest


Name
e-mail

Required, but never shown


Post Your Answer Discard

By clicking “Post Your Answer”, you agree lớn our terms of service, privacy policy & cookie policy


Not the answer you're looking for? Browse other questions tagged google-drive-api or ask your own question.


The Overflow Blog
Featured on Meta
Linked
2
get public shareble link after uploading tệp tin to google drive using nodejs
1
How lớn upload xlsx files lớn my own google drive, then convert them to lớn google spreadsheet & get the shareable link programmatically?
0
How to programmatically nội dung a google drive liên kết on android?
1
Get direct links for unauthorized users on Google Drive API
1
Google drive API shareable liên kết for public
0
Sharing files in Google Drive using Python
0
Get public liên kết to file with Google Drive SDK
1
how lớn get a temporary tải về link for a tệp tin by google drive api
0
Google Drive SDK - Get presentation's "Present" link
Related
4
Sharing tệp tin in Google Drive with public
5
How to lớn get the link of a publicly shared file/folder
5
Linking khổng lồ kml/kmz files on Google Drive
0
Google Drive SDK Public tải về Link
1
Get liên kết to Google Drive presentation file
1
How can i know the original tệp tin name from google drive liên kết using c# code
0
quả táo IPA installation over the air using google drive
1
Google drive api: How to get the absolut liên kết (final) as returnment From my script
1
How to allow viewers to download a tệp tin through Google Drive API
Hot Network Questions more hot questions

Question feed
Subscribe to RSS
Question feed lớn subscribe lớn this RSS feed, copy & paste this URL into your RSS reader.


Stack Overflow
Products
Company
Stack Exchange Network
Site kiến thiết / hình ảnh © 2022 Stack Exchange Inc; user contributions licensed under cc by-sa. Rev2022.5.6.42057


Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device và disclose information in accordance with our Cookie Policy.