How to POST a bitmap to a server using Retrofit/Android -
i'm trying post bitmap server using android
, retrofit
.
currently know how post file, i'd prefer send bitmap directly.
this because user can pick image off device. i'd resize save bandwidth before gets sent server , preferrably not have load it, resize it, save file local storage post file.
anyone know how post bitmap retrofit
?
bitmap bmp = bitmapfactory.decoderesource(getresources(), r.drawable.ic_launcher); bytearrayoutputstream stream = new bytearrayoutputstream(); bmp.compress(bitmap.compressformat.png, 100, stream); byte[] bytearray = stream.tobytearray();
you can convert bitmap byte array , after post byte array server else can make 1 tempory file example
file file = new file(this.getcachedir(), filename);
file directly uplaod server
wiki
Comments
Post a Comment