当前位置:网站首页>由GlideException: Failed DecodePath{DirectByteBuffer->GifDrawable->Drawable}引起的刨根问底
由GlideException: Failed DecodePath{DirectByteBuffer->GifDrawable->Drawable}引起的刨根问底
2022-06-29 23:50:00 【dev晴天】
最近写个demo使用Glide加载图片突然发现图片未加载出来,主要报错:
GlideException: Failed DecodePath{
DirectByteBuffer->GifDrawable->Drawable}
这时感到很奇怪检查下自己的代码,发现图片的url有问题,,,,,
Glide
.with(this)
.load("https://github.com/sunnnydaydev/DataBingding/blob/main/photo/glide_test.png")
.into(binding.img)
这个图片是自己github项目上放的一张图片,可能是受Github#ReadMe的影响,自己平时在Github#ReadMe中插入图片时直接把项目中图片链接以富文本语法插入即可展示图片。因此使用Glide加载这张图片时自己直接就使用了这个链接。
说了半天说说为啥报错吧 其实图片url有问题,这个url在服务器上代表的是一个页面资源,而不是一张具体图片资源。
上面的链接复制到浏览器打开你会发现页面是这样的:

所以Glide拿到这个url http请求后拿到的是整个网页数据。为了能够正确的加载图片,直接指定正确的图片路径即可。
这时便有一个问题了,既然Github#ReadMe中指定了上述的url,为啥他能够正确加载这张图片???
我想应该是网站在解析ReadMe富文本文件时解析到这个url会自动转到图片的真正服务器地址。嗯嗯背后的流程大致应该就是这样。
那么此时我又有个想法,既然图片有真正的服务器地址,我可以找出来吗?这样我以后或许可以专门建个github项目放置图片,然后客户端需要请求在线图片时我就可以在这直接模拟了
通过如下方式被找到了,,,,Github#ReadMe页面:

发现复制图片url粘贴到浏览器后多了一个查询参数?raw = true,然后enter 后神奇出现了

浏览器自动转到了图片所在服务器的url,这个url有规律的:
https://raw.githubusercontent.com/你的Github用户名/Github上你项目中的图片
经过一番探究颇有收获,不过还是有些需要注意的:
- github在国内不稳定老是出现打开超时现象
- raw.githubusercontent.com 这个域名下的资源目前国内好像访问不了,一直请求拒绝。
上述很好解决,程序员吗搞个梯子即可
The end 探究完毕,溜溜球,,,,
边栏推荐
- solo 博客皮肤导入 skins 文件夹后出现 500 错误
- AI empowers new retail, the way to win "wisdom" lies in ecological thinking | selected excerpts from digital intelligence night talk live broadcast
- AI赋能新零售,「智」胜之道在于生态思维|数智夜话直播精选摘录
- After working in the software development industry for six years, I changed my ideas in those years
- Solr basic operation 5
- Shell positional parameter variables and predefined variables
- LC:有效的数独 + 旋转图像
- Ingenious application of golang generics to prevent null pointer errors of variables and structural fields
- 穿越过后,她说多元宇宙真的存在
- Is it safe to open a stock account? Shanghai stock account opening.
猜你喜欢

二叉搜索树 230. 二叉搜索树中第K小的元素 1038. 从二叉搜索树到更大和树

这个简单的小功能,半年为我们产研团队省下213个小时

Applet plug-in access, development and precautions

Why is JSX syntax so popular?

云和恩墨盖国强,识别它、抓住它,在国产数据库沸腾以前

AI赋能新零售,「智」胜之道在于生态思维|数智夜话直播精选摘录

Yunhe enmo Guoqiang, identifiez - le, saisissez - le, avant l'ébullition de la base de données nationale

开始“收割”!钉钉调整“钉钉Teambition”免费用人数上限,超十人将无法正常用

Halcon实用:焊点检出设计思路

Construction of module 5 of actual combat Battalion
随机推荐
Digital collection of cultural relics, opening a new way of cultural inheritance
6.28日刷题题解
What is online account opening? In addition, is it safe to open a mobile account?
Zhongang Mining: Fluorite helps the construction and development of lithium battery in fluorine industry
25 interview questions about Apache
High performance and high availability computing architecture of "microblog comments" in microblog system
Zhongkang holdings opens the offering: it plans to raise HK $395million net, and it is expected to be listed on July 12
请指教同花顺软件究竟是什么?究竟网上开户是否安全么?
數莓派 4怎麼樣?可能的玩法有哪些?
AI赋能新零售,「智」胜之道在于生态思维|数智夜话直播精选摘录
HPE launched ARM CPU general server product
shell-运算符
Cacti maximum monitoring number test
RRDtool 画MRTG Log数据
Which securities company is good for opening a mobile account? In addition, is it safe to open a mobile account?
Solr基础操作4
招商证券靠谱吗?开股票账户安全吗?
After working in the software development industry for six years, I changed my ideas in those years
我想知道今天还可以开户么?另外想问,现在在线开户安全么?
[Shangshui Shuo series] day 8