code: private static String getEncodeFileName(String userAgent, String fileName) {
      String encodedFileName = fileName;
      try {
        if (userAgent.contains("MSIE") || userAgent.contains("Opera")) {
          encodedFileName = URLEncoder.encode(fileName, "UTF-8");
        } else {
          encodedFileName = "=?UTF-8?B?" + new String(BaseEncoding.base64().encode(fileName.getBytes("UTF-8"))) + "?=";
        }
      } catch (Exception e) {
        LOGGER.error(e.getMessage());
      }
  
      return encodedFileName;
    }
docs: Encode header value for Content-Disposition