Glide赢得';t加载一些图像URL


Glide won't load some image URLs

我已经创建了Restful Api,因此用户可以与我的服务器数据库通信。首先,我将用户从Gallery中选择的图像上传到数据库中,使用将位图转换为字符串的功能:

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);
}

之后,我将图像路径存储在数据库中,并使用以下PHP代码解码编码图像:

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

图像的结果是:

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

当我试图从适配器获取这个url时,我一无所获。这是我使用过的代码:

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);
        }

我知道url有问题,因为当我尝试加载一些随机的url时,比如这个:

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

它起作用了。那么我的URL可能出了什么问题呢?

如果有人和我一样有同样的问题,不要忘记放

http://表示您存储在数据库中的图像的路径。对我来说就是这样:

我这样做是错误的:

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

这就是它应该看起来的样子:

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