code: private long calculatePartSize(long fileSize) {
          long partSize = MINIMUM_PART_SIZE;
          int approxNumParts = 1;
          while (partSize * approxNumParts < fileSize && partSize*2 <= MAXIMUM_UPLOAD_PART_SIZE) {
              partSize *= 2;
              approxNumParts *= 2;
          }
          return partSize;
      }
docs: Calculates the part size to use when uploading an archive of the
  specified size using Glacier's multipart upload APIs. Because of the tree
  hashing algorithm, part sizes must be aligned on 2^n MB boundaries (ex:
  1MB, 2MB, 4MB, 8MB, etc). All parts must be the same size, except for the
  last part.
  
  @param fileSize
  The size of the file being uploaded.
  
  @return The part size to use in the multipart upload.