Google云端硬盘中的图像img src = webContentLink? [英] Google Drive images in img src=webContentLink?

查看:267
本文介绍了Google云端硬盘中的图像img src = webContentLink?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用存储在Google云端硬盘中的图片在网站中使用<< img src =< webContentLink> /> ?
$ b 其中< webContentLink> 是在文件上传后返回的,其格式为' https://drive.google.com/uc?id= < FILEID> & export = download'



我只为帐户用户创建了一个小型网站。他们可以将文件上传到他们的谷歌驱动器文件夹,该文件夹的权限设置为与其他用户(仅限特定人员)的帐户共享。这是一个ASP.NET MVC 5网站,使用Google API客户端库.NET。



在Chrome和Firefox中,图像显示效果很好,在IE和Safari中, t显示并返回302状态码。有时,如果您直接在新选项卡中查看图像,然后刷新它显示的网页。它可能还会显示文件夹权限是否设置为任何人有链接,但这并不理想。



文档()说,'如果你想允许用户直接在web浏览器中查看文件,而不是通过API,使用webContentLink。'我明白这可以使用img src =''来直接显示图像而不需要API ,然后它会继续说:'您可以将用户重定向到此网址,或将其作为可点击的链接提供。



那么Google可以确认'webContentLink'可以在img src =''中使用,或者为什么它可以在某些浏览器中使用,而不是在其他浏览器中使用?我已经阅读了很多关于这个的帖子,有些是旧的,有些是最近的。如果它不在img src中使用,我认为应该在文档中说明。



非常感谢

解决方案

显示来自Goggle Drive的图像可以分三步完成: 检索您的图像ID
$ b

右键点击图片并选择共享。
您会看到需要复制的链接。您将从网址中提取图片的ID。



以下是您的共享链接的样子:

  https://drive.google.com/open?id=YourFileId 



检查您的共享设置



只有有权访问这些文件的用户才能看到您的图片。要允许任何人访问您的图片,您需要将共享设置设置为可通过链接显示。 显示您的图片

正确配置您的共享设置和您的图片文件ID ,您现在可以指定如何使用图片显示指定的格式。

  https://drive.google.com/thumbnail?id=YourFileID 

更多细节可以在 here


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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆