我想知道是否可以在公共网站上访问/显示存储在谷歌驱动器中的图像等文件。
当前回答
从谷歌驱动器帮助页面:
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.
其他回答
更新:正如所宣布的,谷歌在2016年8月弃用了此功能。这是谷歌的最后一次更新。
是的,这是可能的。如果你把文件放在公用文件夹中,你可以通过这个URL获取文件夹中的任何文件:
https://googledrive.com/host/<folderID>/<filename>
您可以按照以下步骤将您想要的文件嵌入到您的网站。
在谷歌驱动器中找到PDF文件 在谷歌驱动器中预览PDF文件 弹出谷歌驱动器预览 使用“更多操作”菜单并选择“嵌入项” 提供副本代码 编辑谷歌网站页面,你想嵌入 打开HTML编辑器 粘贴谷歌驱动器预览提供的HTML嵌入代码 使用更新按钮并保存页面
引用:https://www.steegle.com/websites/google-sites-howtos/embed-drive-pdf
去你的谷歌车道。 右键单击映像文件。 选择Get link。 打开“常规访问”下拉菜单。 选择任何人与链接发布您的图像。 单击复制链接>完成。
你会得到一个像下面这样的URL: https://drive.google.com/file/d/1wMgCWAsqlw0nXcMhCldTbwSznMdXUmBT/view?usp=share_link 您可以看到粗体显示的文件ID。将文件ID放在下面的简单视图链接中: https://drive.google.com/uc?id=FILE ID 结果: https://drive.google.com/uc?id=1wMgCWAsqlw0nXcMhCldTbwSznMdXUmBT
你可以对其他类型的文件采取同样的步骤:MP3, PDF等。
功能名称:goobox
标签:图像托管,regex, URL,谷歌驱动器,dropbox,高级
return: string, Returns a string URL that can be used directly as the source of an image. when you host an image on google drive or dropbox you can't use the direct URL of your file to be an image source. you need to make changes to this URL to use it directly as an image source. goobox() will take the URL of your image file, and change it to be used directly as an image source. Important: you need to check your files' permissions first, and whether it's public. live example: https://ybmex.csb.app/
cconst goobox = (url)=>{
let dropbox_regex = /(http(s)*:\/\/)*(www\.)*(dropbox.com)/;
let drive_regex =/(http(s)*:\/\/)*(www\.)*(drive.google.com\/file\/d\/)/;
if(url.match(dropbox_regex)){
return url.replace(/(http(s)*:\/\/)*(www\.)*/, "https://dl.");
}
if(url.match(drive_regex)){
return `https://drive.google.com/uc?id=${url.replace(drive_regex, "").match(/[\w]*\//)[0].replace(/\//,"")}`;
}
return console.error('Wrong URL, not a vlid drobox or google drive url');
}
let url = 'https://drive.google.com/file/d/1PiCWHIwyQWrn4YxatPZDkB8EfegRIkIV/view'
goobox(URL); // https://drive.google.com/uc?id=1PiCWHIwyQWrn4YxatPZDkB8EfegRIkIV
以前的一些用户很接近,但他们在这里或那里遗漏了一个步骤。
这里有一个视频展示了所有的步骤。
当涉及到新的谷歌驱动器时,以下信息是不正确的。对于新谷歌驱动器,请遵循以下说明。 你有两种选择, 选项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)