To send files to server we need to use POST method instead of GET method. I assume that you must know about POST and GET methods and you also know about how to use Retrofit API. and then we will attach ”MultipartTypedOutput” to Body of our response to send over POST method.
First steps is to know what server will respond back when you submit data. and then make Getter Setter of that response. In this example my server will give following response as JSONFeed :
So i will make Getter Setter file according to that response.
So open Android Studio and create new Project , if you want to embed in old project then skip this step.
Now open Build.gradle file of app directory as shown in below screenshot.
and add Retrofit’s compile dependency as shown below :
and click on sync project, and wait till android studio download all required files.
When build finish goto app/java/YOUR_PACKAGE_NAME/ (in this example my package name is com.learnpainless.uploadfiles ).
And create new class for getter-setters, i will name that file as ”ResponsePojo.class“.
and make getter-setters according to Server response. my getter setter will look like below :
Ok so now create new Java Class name it as ”SubmitAPI” and Kind will be Interface. as shown in below screenshot.