问题描述
我可以使用存储在Google云端硬盘中的图片在网站中使用<< img src =< webContentLink> /> ?
$ b 其中< webContentLink> 是在文件上传后返回的,其格式为' < FILEID> & export = download'
我只为帐户用户创建了一个小型网站。他们可以将文件上传到他们的谷歌驱动器文件夹,该文件夹的权限设置为与其他用户(仅限特定人员)的帐户共享。这是一个ASP.NET MVC 5网站,使用Google API客户端库.NET。
在Chrome和Firefox中,图像显示效果很好,在IE和Safari中, t显示并返回302状态码。有时,如果您直接在新选项卡中查看图像,然后刷新它显示的网页。它可能还会显示文件夹权限是否设置为任何人有链接,但这并不理想。
文档(
Can I use images stored in Google Drive to be used in a website by the html,<img src="<webContentLink>" /> ?
Where <webContentLink> is returned after a file is uploaded and is in the format, 'https://drive.google.com/uc?id=<FILEID>&export=download'
I have a small website created for account users only. They can upload files to their google drive folder and this folder has permissions set to share with the accounts of the other users (specific people only). This is an ASP.NET MVC 5 website using the Google API Client Libraries for .NET.
In Chrome and Firefox the images display fine, in IE and Safari they don't show and return a 302 status code. Sometimes if you view the image directly in a new tab and then refresh the web page it shows. It might also show if the folder permission is set to 'anyone with the link', but this isn't ideal.
The documentation (https://developers.google.com/drive/v3/web/manage-downloads) says, 'If you want to allow a user to view a file directly in a web browser instead of through the API, use the webContentLink.' I understood this to be okay to use img src='' to display an image directly without the API, however it then goes on to say, 'You can either redirect a user to this URL, or offer it as a clickable link'.
So can Google please confirm if 'webContentLink' can be used in img src='', or not and why it works in some browsers and not others? I've read many posts on this, some old, some more recent. If it's not to be used in img src I think it should be made clear in the documentation.
Many thanks
Displaying an image from Goggle Drive can be done in 3 steps:
Retrieving your image ID
Right click on your image and select Share.You'll see a link that you need to copy. You will extract the image's ID from the URL.
Here is what your sharing link should look like:
https://drive.google.com/open?id=YourFileId
Check your sharing settings
Your images will only be visible to people who have access to those files. To allow anyone access to your images, you need to set the sharing setting as Visible with the link.
Display your image
With your sharing settings properly configured and your image file IDs at hand, you can now specify how your images will be displayed using a prescribed format.
https://drive.google.com/thumbnail?id=YourFileID
More details can be found here
这篇关于Google云端硬盘中的图像img src = webContentLink?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!