Glide won't load some image URLs

Glide won't load some image URLs



I have created Restful Api, so the user can communicate with my server database. First what i'm uploading image that user choose from Gallery into the database, using function for converting bitmap to string:


public String getStringImage(Bitmap bmp)
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.JPEG, 50, baos);
byte imageBytes = baos.toByteArray();
return Base64.encodeToString(imageBytes, Base64.DEFAULT);



After that i'm storing the image path in database and decoding encoded image using these code in PHP:


if (!is_null($image))
file_put_contents($pathToImage, base64_decode($image));



And the result of the image is this:


http://ashfoundation.net/uploads/82.png



When i try to get this url from adapter, i'm getting nothing. This is the code i have used:


String imagePath = joke.getImagePath();

Uri uri = Uri.parse(imagePath);

if (Uri.EMPTY.equals(uri))
viewHolder.feedImage.setVisibility(View.GONE);
else
Glide.with(mContext)
.load(uri)
.fitCenter()
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.into(viewHolder.feedImage);



I know that something is wrong with the url because when i have tried loading some random url like this one:


https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png



It was working. So what could be wrong with my URL?






Are you sure your url is not https?

– Leonardo Acevedo
May 11 '16 at 4:56






I think that isn't matter.

– Dusan Dimitrijevic
May 11 '16 at 9:19




1 Answer
1



If someone is having the same problem like i do, just don't forget to put



http:// for the path of image which you are storing in database. That was the case for me:


http://



I was doing like this and it is wrong:


if($image === 'null')
$actualpath = "null";
else
$actualpath = "ashfoundation.net/$path";



This is how it supposed to look:


if($image === 'null')
$actualpath = "null";
else
$actualpath = "http://ashfoundation.net/$path";



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)