If you want to send multiple files,Images, Text etc then you need to send that whole data as MultipartTypedOutput. This is same as Multipart Entity in HTTP Client & Post.
this is my server url where i m going to upload files :
http://192.168.1.105/learnpainless/android/file_upload/fileUpload.phpand these are parameters : image,email,website
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 Retrofit2 API. and then we will attach ”MultipartTypedOutput” to Body of our response to send over POST method.
{"file_name":"defiance-wallpaper-1920x1080.jpg","email":"test@gmail.com","website":"www.learnpainless.com","message":"File uploaded successfully!","error":false,"file_path":"http://192.168.1.105/android/file_upload/uploads/defiance-wallpaper-1920x1080.jpg"}
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 Retrofit2’s compile dependency as shown below :
compile 'com.squareup.retrofit2:retrofit:2.1.0'compile 'com.squareup.retrofit2:converter-gson:2.1.0'
String ROOT_URL = "http://192.168.1.105/learnpainless/android/";
Quick Links
Legal Stuff
Social Media