title: Bytes sent from app are not read properly on server
body: <p>I am uploading file using <a href="https://github.com/gotev/android-upload-service" rel="nofollow noreferrer">this</a> library (android-upload-service) from Android. It works fine on <code>local server</code> for all types of media but when I send it to <code>Java Server</code>, server reads on last few bytes. e.g. for a file of <strong>5 MB</strong>, server reads only <strong>71 bytes</strong>.</p>
  
  <p>For same server, files can be uploaded from <strong>iOS device</strong>. What can possibly be wrong when I upload file?</p>
  
  <p>This is the code I use to upload file on server</p>
  
  <pre><code>    MultipartUploadRequest request = new MultipartUploadRequest(context, BuildConfig.SERVER_URL + EndPoints.FILE_UPLOAD);
      if (report.isFileUri()) {
          request.addFileToUpload(new File(report.getContentUri().getPath()).getAbsolutePath(), "file");
      } else {
          request.addFileToUpload(report.getContentUri().toString(), "file");
      } 
  
      RequestHeaders requestHeaders = new NactaEaseConfig().defaultHeaders(context);
      if (requestHeaders == null) {
          throw new Exception("Required headers are not available. Quitting.");
      }
  
      request.addHeader(EaseRequest.TOKEN_KEY, EaseTokenManager.getToken(context));
  
      Map&lt;String, String&gt; headers = requestHeaders.get();
      for (String key : headers.keySet()) {
          request.addHeader(key, headers.get(key));
      }
  
      request.addParameter("reportedLive", report.getLiveReportingString())
              .addParameter("draftsCreatedDate", report.getFormattedTimeForUpload())
              .addParameter("incident_type", report.getReportType())
              .addParameter("file", report.getFileName())
              .addParameter("incident_location", report.getCompleteAddress())
              .addParameter("app_user_location", report.getLocation())
              .addParameter("show_identity", report.getShareNumberString())
              .addParameter("description", report.getDetails())
              .addParameter("mobile_number", user.getMobileNumber())
              .addParameter("area_name", report.getArea())
              .addParameter("city_name", report.getCity())
              .addParameter("content_type", report.getServiceContentType())
              .setMaxRetries(0);
      request.startUpload();
  </code></pre>
  
  <p>And these are the logs I get while uploading file.</p>
  
  <pre><code>D/UploadService: UploadRequest - null or empty upload ID. Generating it
  D/UploadService: UploadRequest - Created new upload request to http://124.109.32.137:8080/NACTA/REST/Communicator/FileUpload with ID: 1034ab15-a10c-41c6-8f36-5697b4dffb81
  D/UploadService: MultipartUploadRequest - Auto-detected MIME type for content://com.android.providers.media.documents/document/video%3A146 is: video/mp4
  D/UploadService: MultipartUploadRequest - Using original file name: VID_20171216_223940.mp4
  I/UploadService: UploadService - Starting service with namespace: com.es.tatheer, upload pool size: 2, 5s idle thread keep alive time. Foreground execution is enabled
  D/UploadService: UploadService - Successfully created new task with class: net.gotev.uploadservice.MultipartUploadTask
  D/UploadService: FileUploader - Starting upload task with ID 1034ab15-a10c-41c6-8f36-5697b4dffb81
  D/UploadService: MultipartUploadTask - 466841
  D/UploadService: OkHttpStackConnection - creating new connection
  D/UploadService: UploadTask - Broadcasting upload progress for 1034ab15-a10c-41c6-8f36-5697b4dffb81: 103 bytes of 468370
  D/UploadService: UploadTask - Broadcasting upload progress for 1034ab15-a10c-41c6-8f36-5697b4dffb81: 361928 bytes of 468370
  D/UploadService: MultipartUploadTask - 468323
  D/UploadService: UploadTask - Broadcasting upload progress for 1034ab15-a10c-41c6-8f36-5697b4dffb81: 468370 bytes of 468370
  D/UploadService: FileUploader - Server responded with HTTP 200 to upload with ID: 1034ab15-a10c-41c6-8f36-5697b4dffb81
  D/UploadService: UploadTask - Broadcasting upload completed for 1034ab15-a10c-41c6-8f36-5697b4dffb81
  D/UploadService: UploadService - All tasks completed, stopping foreground execution
  I/UploadService: UploadService - Service will be shut down in 10000ms if no new tasks are received
  D/UploadService: OkHttpStackConnection - closing connection
  I/UploadService: UploadService - Service is about to be stopped because idle timeout of 10000ms has been reached
  D/UploadService: UploadService - Stopping foreground execution
  D/UploadService: UploadService - UploadService destroyed
  </code></pre>