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?
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.
Are you sure your url is not https?
– Leonardo Acevedo
May 11 '16 at 4:56