当前位置:网站首页>由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 探究完毕,溜溜球,,,,
边栏推荐
- I wonder if I can open an account today? In addition, is it safe to open an account online now?
- The role of VMware virtual machine
- golang7_ TCP programming
- Start harvesting! Nailing: adjust the maximum number of free users of "nailing team". If the number exceeds 10, it will not work normally
- Head on Amway! Good looking and practical motor SolidWorks model material see here
- FPGA Development (2) -- IIC communication
- Siemens low code platform connects MySQL through database connector to realize addition, deletion, modification and query
- Official website of Greentree
- @Scheduled注解的坑,我替你踩了
- 雲和恩墨蓋國强,識別它、抓住它,在國產數據庫沸騰以前
猜你喜欢
![[译]在软件开发行业工作 6 年后,那些年我曾改过的观念](/img/69/c9829b14223f1e8fd3137d0750d8f7.png)
[译]在软件开发行业工作 6 年后,那些年我曾改过的观念

333333333333333333333333333333

雲和恩墨蓋國强,識別它、抓住它,在國產數據庫沸騰以前

Applet plug-in access, development and precautions

6.29日刷题题解

【一起上水硕系列】Day 8

Use of jetpack's room in combination with flow

Siemens low code version 9.14: meet different needs

西门子低代码 9.14版本: 满足不同需求

二叉树的序列化 力扣 297. 二叉树的序列化与反序列化 652. 寻找重复的子树
随机推荐
RRDtool 画MRTG Log数据
这个简单的小功能,半年为我们产研团队省下213个小时
6.29日刷题题解
Serialization of binary tree 297 Serialization and deserialization of binary tree 652 Find duplicate subtrees
[译]在软件开发行业工作 6 年后,那些年我曾改过的观念
Et la tarte aux framboises 4? Quels sont les jeux possibles?
雲和恩墨蓋國强,識別它、抓住它,在國產數據庫沸騰以前
简单理解B树和B+树
koa2学习和使用
Cacti maximum monitoring number test
AI empowers new retail, the way to win "wisdom" lies in ecological thinking | selected excerpts from digital intelligence night talk live broadcast
一步步教你在Edge浏览器上安装网风笔记
Create an API rapid development platform, awesome!
Leetcode (76) -- Minimum Covering substring
333333333333333333333333333333
云和恩墨盖国强,识别它、抓住它,在国产数据库沸腾以前
Use of jetpack's room in combination with flow
Which securities company is good for opening a mobile account? In addition, is it safe to open a mobile account?
I wonder if I can open an account today? In addition, is it safe to open an account online now?
Head on Amway! Good looking and practical motor SolidWorks model material see here