I’m using this method to upload files to my server:
@Multipart @POST("new") Call<Response> send(@Part("myFile") byte file);
I have been reading and some people use
TypedFile to do it, and maybe this is easier than send raw bytes like I’m doing.
TypedFile class is in
retrofit.mime package. But I don’t have it there. Has this package been removed from 2.0 version? Or do I have to add another dependency? If so, which one?
In 2.0 you need to use RequestBody instead of TypedFile. Get file with RequestBody
RequestBody file = RequestBody.create(MediaType.parse("image/*"), path);
Use it in your request
@Multipart @POST("new") Call<Response> send(@Part("myFile") RequestBody file);