Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- File origFile = new File(PathHolder);
- String getDirPath = origFile.getParent();
- RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), getDirPath);
- multipartBody = MultipartBody.Part.createFormData("uploadFiles",origFile.getName(),requestFile);
- new UploadFileAsyncTask().execute();
- protected notificationVO doInBackground(Void... params) {
- notificationVO res;
- WebserviceImpl webservices = new WebserviceImpl();
- res = webservices.notifyAttachment(token,multipartBody, getContext());
- Log.e("File","browse uploaded");
- return res;
- }
- @Multipart
- @POST("upload")
- public Call<notificationVO>notifyAttachment(@Query("token")String token,
- @Part MultipartBody.Part attachFile); // @Part MultipartBody.Part file
- public notificationVO notifyAttachment(String token,MultipartBody.Part fileUri,final Context context){
- WebservicesApi mRestAPIWService = ApiUtilsForWS.getAPIService(context,);
- Call<notificationVO> call = mRestAPIWService.notifyAttachment(token,fileUri);
- try {
- Response<notificationVO> response = call.execute();
- if(response.isSuccessful())
- {
- Log.e(TAG,"Success."+response.code());
- return response.body();
- }
- else
- {
- Log.e(TAG,"Failed."+response.code());
- return null;
- }
- } catch (IOException e1) {
- e1.printStackTrace();
- return null;
- }
- }
Add Comment
Please, Sign In to add comment