问题描述
有没有一种方法可以强制下载链接,而不是通过浏览器尝试打开文件?在这种情况下,我有一个docs电子表格和一些mp3文件的链接.我希望用户下载这些文件,而不是通过浏览器播放这些文件. mp3托管在另一个站点上.谢谢,博
Is there a way to force a download link instead of the browser trying to open the file? In this case I have a docs spreadsheet and a some links to mp3 files. I want the users to download these files instead of the browser playing it. The mp3's are hosted on another site.Thanks, Bo
推荐答案
要为文档建立下载链接- https://docs.google.com/feeds/download/documents/导出?docID = yourDocId
To make download links for documents -https://docs.google.com/feeds/download/documents/Export?docID=yourDocId
要为任何文件建立下载链接- https://docs.google.com/uc?id= yourDocId& export = download& hl = zh_CN
To make download links for any file -https://docs.google.com/uc?id=yourDocId&export=download&hl=en_US
要制作电子表格的下载链接- https://spreadsheets.google.com/feeds/下载/电子表格/导出?key = yourDocId& exportFormat = csv
To make download links for spreadsheets -https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=yourDocId&exportFormat=csv
有关更多信息,请在此处
2018年更新
新的下载URL 是
https://docs.google.com/spreadsheets/d/<KEY>/export?gid=<GID>&format=csv
,其中<KEY>
和<GID>
可以从您的导航URL 中获得,
https://docs.google.com/spreadsheets/d/<KEY>/edit#gid=<GID>
The new download URL is
https://docs.google.com/spreadsheets/d/<KEY>/export?gid=<GID>&format=csv
where <KEY>
and <GID>
can be obtained from your navigation's URL,
https://docs.google.com/spreadsheets/d/<KEY>/edit#gid=<GID>
PS:电子表格(工作簿)可能有多个工作表(工作表), GID 是所需的工作表ID.单页电子表格通常具有gid=0
,但是如果添加更多,它们将具有随机数(即使更改制表符顺序,也会保留 GID ).
PS: spreadsheets (workbook) may have multiple sheets (worksheets), GID is the desired sheet ID. One-sheet-spreadsheet usually has gid=0
, but if you add more they'll have random numbers (the GID is preserved even changing tab-order).
因此,使用wget
或curl
您可以进行测试,
So, using wget
or curl
you can test,
wget --no-check-certificate -O test.csv \
'https://docs.google.com/spreadsheets/d/0At2sqNEgxTf3dEt5SXBTemZZM1gzQy1vLVFNRnludHc/export?gid=0&format=csv'
这篇关于在Google文档电子表格上强制下载链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!