Before i will start i see a lot of questions about this but nothing works for me maybe someone can explained or display it to me how can compress bitmap to MultiPart entity and than send it to the server correct using Retrofit
Bitmap to MultiPartEntity using retrofit
5k views Asked by moshe kobi At
2
There are 2 answers
0
On
For those who come here for solution, here's mine.
First create a temporary file based on that bitmap
Convert Bitmap to file in Android (Stack Overflow)
Then get that file and add as multipart file
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file);
MultipartBody.Part fileBody = MultipartBody.Part.createFormData("imageFile", file.getName(), requestFile);
First you create a ResponseBody of the file and parse it as a MultipartBody.Part:
This filePart can then be passed to your Retrofit Service, which should look like this: