0

I am trying to make an app that includes uploading images with multipart using Retrofit 2, i haven't been able to figure out how to count how many files that has been sent ?

i am using this answer as a way to count how many percent that i have uploaded but it doesn't really count how many file that i have uploaded.

this is how i initiate my request using retrofit

 HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();

        uploadService = new Retrofit.Builder().baseUrl("http://someserver.com/").client(client).build().create(UploadService.class);

MultipartBody.Part[] spajImageParts = new MultipartBody.Part[mCompressedFileFormate.size()];

        for (int index = 0; index < mCompressedFileFormate.size(); index++) {
            File f = new File(mCompressedFileFormate.get(index).getPath());
            ProgressRequestBody fileBody = new ProgressRequestBody(f, this);

            spajImageParts[index] = MultipartBody.Part.createFormData("upload", no_spa + f.getName(), fileBody);
        }

    RequestBody name = RequestBody.create(MediaType.parse("text/plain"), "upload_test");
            retrofit2.Call<okhttp3.ResponseBody> req = uploadService.postImage(spajImageParts, name);
            req.enqueue(new Callback<ResponseBody>() {

0 Answers0