我想知道是否可以在公共网站上访问/显示存储在谷歌驱动器中的图像等文件。
当前回答
从谷歌驱动器帮助页面:
To host a webpage with Drive: Open Drive at drive.google.com and select a file. Click the Share button at the top of the page. Click Advanced in the bottom right corner of the sharing box. Click Change.... Choose On - Public on the web and click Save. Before closing the sharing box, copy the document ID from the URL in the field below "Link to share". The document ID is a string of uppercase and lowercase letters and numbers between slashes in the URL. Share the URL that looks like "www.googledrive.com/host/[doc id] where [doc id] is replaced by the document ID you copied in step 6. Anyone can now view your webpage.
其他回答
对于图像,在谷歌查看器中打开图像。即。
方法1
https://docs.google.com/file/d/0Bz7qe_olclTwWDNJRDRmb1pJamM/edit
然后查看源>找到单词“texmex-thumb”,旁边会有链接。
然而,这个答案很简单,事实上非常简单,是的,许多人都提到了它,简单地把图像的id放在下面的链接https://drive.google.com/uc?export=view&id={fileId}
但不管这有多简单,我还是编写了一个脚本在控制台中运行。 从谷歌驱动器中输入一个完整的可共享链接数组,并将它们转换为上述链接。然后它们可以简单地用作静态地址。
array = ['https://drive.google.com/open?id=0B8kNn6zsgGEtUE5FaGNtcEthNWc','https://drive.google.com/open?id=0B8kNn6zsgGEtM2traVppYkhsV2s','https://drive.google.com/open?id=0B8kNn6zsgGEtNHgzT2x0MThJUlE'] function separateDriveImageId(arr) { for (n=0;n<arr.length;n++){ str = arr[n] for(i=0;i<str.length;i++){ if( str.charAt(i)== '=' ){ var num = i+1; var extrctdStrng = str.substr(num) } } console.log('https://drive.google.com/uc?export=view&id='+extrctdStrng) window.open('https://drive.google.com/uc?export=view&id='+extrctdStrng,'_blank') } } separateDriveImageId(array)
您可以按照以下步骤将您想要的文件嵌入到您的网站。
在谷歌驱动器中找到PDF文件 在谷歌驱动器中预览PDF文件 弹出谷歌驱动器预览 使用“更多操作”菜单并选择“嵌入项” 提供副本代码 编辑谷歌网站页面,你想嵌入 打开HTML编辑器 粘贴谷歌驱动器预览提供的HTML嵌入代码 使用更新按钮并保存页面
引用:https://www.steegle.com/websites/google-sites-howtos/embed-drive-pdf
特别针对G-Suite用户 . 如第3点所述,您可以使用此URL托管映像
https://drive.google.com/a/domain.com/thumbnail?id=imageID
有以下替换
域名:替换为贵公司的GSuite域名,如皮卡丘 imageID:替换为镜像id /文件id
这里的先决条件是,图像应该通过驱动器共享给目标受众(无论是单独的每个人还是整个组织)
如果你遇到渲染图像大小的问题,请使用下面提到的选项
https://drive.google.com/a/domain.com/thumbnail?id=imageID&sz=w{width}-h{height}
使用以下替换(除了domain和imageID替换)
{width}:以像素为单位写宽度(不带大括号),如300 {height}:以像素为单位(不带大括号)写高度,例如200
牛科技提供的解决方案对我很有效。
http://googledrive.com/host/<folderID>/<filename>
但有两个突出的问题
您不能在驱动器中的同一文件夹中有两个具有相同名称的文件,否则此链接将不起作用。 目前还不清楚,但谷歌似乎计划通过驱动器弃用图像托管。请看下面的链接。 https://support.google.com/richmedia/answer/6098968?hl=en