Bạn đang xem: How to get get the "shareable link" of a google drive file via google apps script?
Google Drive URL Tricks

Google Drive website ViewerGoogle Drive includes a built-in web viewer so people can view your shared files - from Microsoft Office documents to lớn videos lớn AutoCAD drawings - directly in their browser. You can use this web viewer lớn view online files without having to download the files khổng lồ your computer.
https://docs.google.com/viewer?url=FILE_URL
Replace FILE_URL with the full http links of the online document và anyone can view your file in the browser itself. Here’s an example.
Reader Mode for Google Drive FilesYou can view native Google documents in reader mode (sans the Google UI) by simply replace /edit in the Google Drive tệp tin URL with /preview.
So if the original share liên kết of a file in Google Drive is:
https://docs.google.com/spreadsheets/d/SHEET_ID/edit
You can view the same document in a clean, reader mode using the link:
https://docs.google.com/spreadsheets/d/SHEET_ID/preview
Here’s a Google Sheet, Google Document & Google Slides presentation in preview mode that is less-cluttered without any menus & toolbars và thus loads faster.
Embed Google Documents in web PagesThe /preview is useful when you need to embed a document, spreadsheet or presentation from Drive in your web page using the IFRAME tag as in this live example.
iframe>
Download and Export Google Drive Files
The native tệp tin viewer is useful but sometimes you may want to bypass the built-in Google Docs viewer và force the browser to download the tệp tin instead of opening it. Thus if a user has Photoshop on their computer, the PSD file that you have shared through Google Drive will xuất hiện in Photoshop & not in their web browser.Create Direct tải về Links and Skip the web ViewerWhen you upload any file in Google Drive & share it, the shared liên kết looks like this:
https://drive.google.com/open?id=DRIVE_FILE_ID
The FILE_ID is quality for every tệp tin in Google Drive. If you copy this FILE_ID và use it in the URL below, you’ll get a direct links to download the file from Google Drive (example).
https://drive.google.com/uc?export=download&id=DRIVE_FILE_ID
If you wish to open the file in the Google Drive web viewer, the viewer URL would be (example):
https://drive.google.com/file/d/DRIVE_FILE_ID/view
Direct tải về Links for Native Google DocumentsThe directly tải về URL trick works for native Google documents as well. This comes really handy if you want to lớn give users an option to tải về your Google Document as a read-only PDF tệp tin or your Google Spreadsheet as an Excel XLS file.
Google Docs - Direct DownloadsAny document in your Google Drive has a URL like:
https://docs.google.com/document/d/DOC_FILE_ID/edit
Replace /edit with /export?format=, add the file format that the document should be saved as và your tải về link is ready (example).
https://docs.google.com/document/d/DOC_FILE_ID/export?format=pdfhttps://docs.google.com/document/d/DOC_FILE_ID/export?format=doc
The above link will now tải về the same Google document in Word (.docx) và PDF formats. You can also specify txt, html, odt (OpenDocument) or epub for downloading the Google Document as an e-book.
Xem thêm: Tận Dụng Mật Vịt Xiêm Có Tác Dụng Gì, Thận Trọng Khi Dùng Mật Vịt Chữa Sỏi
Google Slides - tải về LinksLike Google Documents, the URLs of presentations in Google Drive have this format:
https://docs.google.com/presentation/d/PRESENTATION_ID/edit
The direct download links for Google Slides is slightly different then Google Documents. Here replace /edit with /export/format where format can be pptx for downloading Google Slides as Microsoft Powerpoint files or PDF for exporting the presentation as a PDF slideshow.
https://docs.google.com/presentation/d/PRESENTATION_ID/export/pdfhttps://docs.google.com/presentation/d/PRESENTATION_ID/export/pptx
The direct liên kết for downloading the same presentation deck in PowerPoint (.pptx) and PDF formats are below:For instance, here’s a presentation on Google Slides that you directly download as a PDF or a PPT file.
Download Google Slides as PNG FilesWith Google Slides, you can either export the entire presentation as a PDF or you can create links to individual slides that will tải về the slide as a high-res PNG file.
All you need to vì is địa chỉ cửa hàng ?pageid=pPAGE_NUMBER khổng lồ the export url. So if I were to download the 10th slide as a PNG file, the URL would be:
https://docs.google.com/presentation/d/FILE_ID/export/png?pageid=p10
Also see: links Directly lớn specific Google Slide
Google Sheets - Export LinksOpen your Google Spreadsheet in Google Drive, make the sheet Public (or giới thiệu with Anyone with a link) và make a chú ý of the shared URL. It should be something like this:
https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit
The direct download links for Google Sheets are similar to lớn Google Docs and the sheets can be exported as PDF, Excel XLSX & CSV files.
https://docs.google.com/spreadsheets/d/FILE_ID/export?format=xlsxhttps://docs.google.com/spreadsheets/d/FILE_ID/export?format=pdfhttps://docs.google.com/spreadsheets/d/FILE_ID/export?format=csv
For instance, here’s the COVID-19 spreadsheet & you can directly download the file as PDF or XLS file with simple manipulation of the original sheet URL.
Also see: e-mail Google Sheets on Schedule
Copy & Make any shared Google Drive file your ownReplace /edit with /copy in the URL of any native Google Drive file and anyone can click that link to quickly make a copy of that tệp tin in their own Google Drive. Try here.
Original Link:https://docs.google.com/document/d/FILE_ID/editCopy Link:https://docs.google.com/document/d/FILE_ID/copy
The /copy URL trick works for Google Docs, Sheets, Slides and Google Scripts. địa chỉ ?copyComments=true if you would like the copied document lớn include the comments from the original document. Mix includeResolvedCommentsOnCopy=false to lớn skip copying resolved comments và copyCollaborators=false to not mô tả the copied document with the original collaborators.
You can use it for Google Forms as well but the khung will be copied khổng lồ another user’s Google trương mục only if the size owner has granted access to the form.
Invite users when copying documentsIf you địa chỉ cửa hàng userstoinvite=email
domain.com to lớn the copy URL, the Google user who is copying the document will be prompted to giới thiệu the document with the specific Google tài khoản immediately after copying the document.
https://docs.google.com/document/d/FILE_ID/copy?userstoinvite=emailaddres
Google Drawings - Embed as ImageYou can export your Google Drawings as SVG, PNG, JPEG or PDF files by replace /edit in the drawing URL with /export/FORMAT.
For instance, if the Google Drawing URL in Drive is:
https://docs.google.com/drawings/d/FILE_ID/edit
The direct link for downloading the drawing in vector format like SVG or as a PDF tệp tin would be:
https://docs.google.com/drawings/d/FILE_ID/export/svghttps://docs.google.com/drawings/d/FILE_ID/export/pdfhttps://docs.google.com/drawings/d/FILE_ID/export/jpg
You can even use these link to embed Google Drawings as inline images in your HTML webpages using the

Also see: The Most Important Google URLs