java - how to create a server that send image from a request images from Glide? -
i'm using glide
image loader client. , create own server java.
my server's code:
file f = new file(imagelocation); try{ bi = imageio.read(f); }catch (exception e){ f = new file(imagelocation); bi = imageio.read(f); } respond = "http/1.1 200 ok\r\n"; respond += "date: " + localdatetime.now() + "\r\n"; respond += "content-type: image/png\r\n"; respond += "content-length: " + f.length() + "\r\n"; respond += "connection: keep-alive\r\n"; respond += "\r\n"; output.write((respond).getbytes()); output.flush(); imageio.write(bi,"jpg",output); output.flush();
i tested browser , work fine, when call using glide
android, no image displayed
the content-length
may confuse glide, because you're lying it, original file length may not same re-encoded jpg output.
you're lying content-type
because it's jpg, not png state it, think glide ignore that.
i think better send imagelocation
's bytes output
, content-length
can predicted simply.
i still trying figure how exception glide if exist
as stated in google groups discussion, read https://github.com/bumptech/glide/wiki/debugging-and-error-handling , suggest add .listener(new requestlistener...)
before .into(imageview)
, log arguments see what's going on.
Comments
Post a Comment