0
public void updateImage(){

    EventDetail eventDetail = new EventDetail();
    SharedPrefManager sfm = SharedPrefManager.getInstance( context );
    ProfileDetail pd = sfm.getUser();
    int eventID=getIntent().getIntExtra( eventDetail.getEventId(),0);

    RequestBody requestBodyuserid = RequestBody.create(MediaType.parse("multipart/form-data"), String.valueOf(pd.getUserId()));
    RequestBody requestBodyeventid = RequestBody.create(MediaType.parse("multipart/form-data"), String.valueOf(eventID));

    imagepart = null;
    File file = new File(move.getPath());

    RequestBody requestBodysubFile = RequestBody.create(MediaType.parse("image/*"), file);
    imagepart = MultipartBody.Part.createFormData("sub_file",file.getName(),requestBodysubFile);



    Api api = RetrofitClient.getApi().create(Api.class);
    Call<ApiResponseWhitoutResData> call = api.uplodeFile(requestBodyuserid,requestBodyeventid ,imagepart);
    call.enqueue( new Callback<ApiResponseWhitoutResData>() {
        @Override
        public void onResponse(Call<ApiResponseWhitoutResData> call, Response<ApiResponseWhitoutResData> response) {

            if (response.body().getResCode()  ==  1){
                Log.d("user", String.valueOf(imagepart));
                Log.d("5",response.body().getResMessage());
                Log.d("1234","abc");
                Log.d("hiral", String.valueOf(requestBodyuserid));

                Toast.makeText( PopActivity.this, response.body().getResMessage(), Toast.LENGTH_LONG ).show();

            }
            else {
                Toast.makeText( PopActivity.this, response.body().getResMessage(), Toast.LENGTH_LONG ).show();
            }
        }

        @Override
        public void onFailure(Call<ApiResponseWhitoutResData> call, Throwable t) {
            Log.d( "fail",""+t.getLocalizedMessage() );
            Toast.makeText( PopActivity.this,"Faild" , Toast.LENGTH_LONG ).show();
        }
    } );
}

getting this in my logcat

2020-06-22 18:50:28.384 28916-28949/com.aswdc.archdaily D/OkHttp: --> POST http://www.eatfresh.cc/arch_daily/api/addSubFile
2020-06-22 18:50:28.384 28916-28949/com.aswdc.archdaily D/OkHttp: Content-Type: multipart/form-data; boundary=39e44899-905e-4a76-9580-52ab78cfc42f
2020-06-22 18:50:28.386 28916-28949/com.aswdc.archdaily D/OkHttp: Content-Length: 599
2020-06-22 18:50:28.392 28916-28916/com.aswdc.archdaily D/fail: /document/image:418347 (No such file or directory)
2020-06-22 18:50:28.427 28916-28916/com.aswdc.archdaily I/Choreographer: Skipped 2 frames!  The application may be doing too much work on its main thread.
2020-06-22 18:50:28.522 28916-28916/com.aswdc.archdaily I/Choreographer: Skipped 4 frames!  The application may be doing too much work on its main thread.
2020-06-22 18:50:28.552 28916-28916/com.aswdc.archdaily I/Choreographer: Skipped 1 frames!  The application may be doing too much work on its main thread.
aytek
  • 1,842
  • 24
  • 32
  • Can you add some details about your problem? What do you want to do and what happened? – aytek Jun 22 '20 at 14:15
  • `move` appears to be a `Uri`, not a file. You cannot treat a `Uri` as a file. See https://stackoverflow.com/a/56308643/115145 – CommonsWare Jun 22 '20 at 14:34

1 Answers1

0

if you open documents provider while file pick then Uri you get back differs depend on file source. [API level 19 & above] See Getting error (No such file or directory) while uploading file with retrofit