Hello. How to transfer a file (jpeg, png, jpg) to a variable via POST in Retrofit 2? There is such a request:
The request from the screenshot above normally works in Postman. The application has the ability to send along with other data and file. If I do not send the file, then I use the following code:
@FormUrlEncoded @POST("create_user") Call<String> addUser(@Query("token") String token, @FieldMap Map<String, Object> params);
Map<String, Object> params = new HashMap<>(); params.put("user_id", какое-то_значение); params.put("login", какое-то_значение); params.put("password", какое-то_значение); ApiController.addUser(getToken(getActivity()), params); This code is working fine. That is, if the user does not send the file, then everything works. Tell me, please, what you need to finish to be able to send the file. Previously, I reworked the image in base64 and, as a string, inserted it into one of the fields in the request. But now you need to make a request exactly as in the screenshot in Postman.