Android Retrofit 2 File Upload
I'm using Retrofit 2 and I want to call a web service to upload my images to my server. Server side i'm using Phalcon PHP and I check if I have a file to upload. But I have never a
Solution 1:
instead of @Part("file") MultipartBody.Part file
use@Part MultipartBody.Part file
Filefile=newFile(getRealPathFromURI(data.getData()));
RequestBodyrequestFile= RequestBody.create(MediaType.parse("multipart/form-data"), getRealPathFromURI(data.getData()));
MultipartBody.PartmultipartBody=MultipartBody.Part.createFormData("file",file.getName(),requestFile);
Post a Comment for "Android Retrofit 2 File Upload"