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


当前回答

更新:正如所宣布的,谷歌在2016年8月弃用了此功能。这是谷歌的最后一次更新。

是的,这是可能的。如果你把文件放在公用文件夹中,你可以通过这个URL获取文件夹中的任何文件:

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

其他回答

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

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

去你的谷歌车道。 右键单击映像文件。 选择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 

更新:正如所宣布的,谷歌在2016年8月弃用了此功能。这是谷歌的最后一次更新。

是的,这是可能的。如果你把文件放在公用文件夹中,你可以通过这个URL获取文件夹中的任何文件:

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

1.将您的图片设置更改为公共。

2.获取其可共享链接。

3.去这个网站并生成一个直接下载链接。

为我工作!