我想知道是否可以在公共网站上访问/显示存储在谷歌驱动器中的图像等文件。


当前回答

如果你想在浏览器中查看文件,也可以使用类似于rufo和Torxed提供的方法:

https://drive.google.com/uc?export=view&id={fileId}

其他回答

我认为这是可能的,但只是在短时间内

你要做的就是将文件的访问控制列表设置为公共只读(或公共读/写)。您可以通过编程方式使用谷歌文档列表API,或手动通过驱动器图像查看器上的“共享”按钮来实现这一点。

然后,您可以通过使用谷歌文档列表API或使用谷歌驱动器API(即Java中的file.getDownloadUrl())以编程方式获取图像的URL。您还可以通过在谷歌驱动器默认图像查看器中右键单击图像,轻松地手动获取到图像的链接。

问题是,这个链接存在的时间是有限的,所以它会工作一段时间,然后就停止工作了。

基本上,存储在驱动器中的图像文件的URL应该是可以访问的,而不需要任何身份验证,一旦它被设置为公开共享,但URL将在某个时候改变。我们可能会在未来找到一个解决方案,比如提供一个永久的URL,将重定向到这些不断变化的URL,但没有承诺…

牛科技提供的解决方案对我很有效。

http://googledrive.com/host/<folderID>/<filename>

但有两个突出的问题

您不能在驱动器中的同一文件夹中有两个具有相同名称的文件,否则此链接将不起作用。 目前还不清楚,但谷歌似乎计划通过驱动器弃用图像托管。请看下面的链接。 https://support.google.com/richmedia/answer/6098968?hl=en

以前的一些用户很接近,但他们在这里或那里遗漏了一个步骤。

这里有一个视频展示了所有的步骤。

当涉及到新的谷歌驱动器时,以下信息是不正确的。对于新谷歌驱动器,请遵循以下说明。 你有两种选择, 选项1,你可以点击右上角的齿轮,恢复到旧的谷歌驱动器,如果你恢复,使用“结束编辑”后的说明) . 选择二,或者你可以跟着我找到的工作。如果我找到比这更好的方法,我会更新它,但以下是我发现的有效方法。

The full link will look like this "https://googledrive.com/host/(folder id) Part one of your link that you need is "https://googledrive.com/host/" for the second half you will need to navigate to the file you would like to share. Once you are in the folder with the file you would like to share, look at the link above (Example 1 https://drive.google.com/drive/u/0/#folders/0B3UALYkiLexYSXZlcldoU2NpYXM ) (Example 2 https://drive.google.com/drive/u/0/#folders/0B3UALYkiLexYSXZlcldoU2NpYXM/0B3UALYkiLexYRkNnOVhsUVozRU0) In both of these above examples, the "Folder ID" you need for sharing is the last group of letters and numbers after the "/" so in example one, it is "0B3UALYkiLexYSXZlcldoU2NpYXM" in example two it is "0B3UALYkiLexYRkNnOVhsUVozRU0" In the examples I used, example 1 was a folder on my drive, and example 2 was a folder inside that first one, that is why it has the entire first link before the second. We only need the section after the "/" furthest to the right.

现在你有了你的“文件夹ID”,使用上面的公式“https://googledrive.com/host/(folder ID)” 例1 https://googledrive.com/host/0B3UALYkiLexYSXZlcldoU2NpYXM 例2 https://googledrive.com/host/0B3UALYkiLexYRkNnOVhsUVozRU0

很好,现在您有了这个链接,在一个新页面中打开它。它将引导您到共享文件夹。一旦在那里,你可以右键单击任何文件,选择“复制链接地址”,或者你可以单击该文件夹中的任何文件,它会带你到托管图像,页面顶部的URL是托管URL。

你就该这么做。这很烦人,就我个人而言,恢复到旧的谷歌驱动器似乎容易得多。

我会尽快制作新的教程视频

如果这对你不起作用,请告诉我你遇到了什么问题。

结束编辑)

https://www.youtube.com/watch?v=QmN22LMPdDk&feature=youtu.be

或者你可以按照下面的书面说明来做。

这些图片和步骤中列出的图片是一致的。

https://googledrive.com/host/0B3UALYkiLexYSXZlcldoU2NpYXM/

Create a Folder on your Google Drive that you would like to use for sharing images. Select that folder and go to the sharing options. Change the "Who has access" options from "Specific People" to "Public on the web" All images placed in folder will have a hosting link on them shown in Step 4 (Images : Change Folder Option.png, Change folder option 2.png, and Change folder option 3.png) place an image in that folder. select the image you would like to share and look at the details section (usually on right hand side) for a section labeled "Hosting" you should find a link that starts with "googledrive.com/host/(random numbers and digits that are the ID for that folder)/(file name)" Use that link to share your images. You can use that link to embed them into other websites. (Images: Change folder option 4.png and Change folder option share.png)

编辑:截至2020年,这是有效的。以前的大多数答案都过时了。

简单的解决方案

你所要做的就是打开你的文件:

然后,进入你的网页检查器(Chrome, Cmd-Shift-I或Ctrl-Shift-I取决于你的操作系统),并获得链接。将该链接粘贴到浏览器中,它将重定向到另一个链接。复制新的URL。完成了!


重定向的目的是什么?

似乎如果你使用第一个链接,它只能在登录到你的谷歌帐户时才能访问。对其他人没有多大帮助。然而,第二个重定向链接不需要您登录。这就是它背后的基本原理。


我删除了图像中显示的原始文件,但这里有另一个工作示例。


实际上,我已经检查了大约一周前在我的编辑中发布的示例链接,但它似乎不再工作了。看起来这些链接只是临时工作,所以不要在任何生产环境中使用它们。

我发现了一个非常有用的api/url:

imageId ->文件ID Width,期望的宽度(不能大于图像分辨率宽度),必须为整数才能工作 高度,期望的高度(不能大于图像分辨率高度),必须为整数才能工作

https://drive.google.com/thumbnail?id=${imageId}&sz=w${width}-h${height}

注意:api/url将保持纵横比,因此它将在第一个维度停止