code: public <T> Attachment attachFile(String url, T t, String partName, InputStream inputstream, String contentType, String attachmentName)
              throws SmartsheetException {
          Util.throwIfNull(inputstream, contentType);
          Attachment attachment = null;
          final String boundary = "----" + System.currentTimeMillis() ;
  
          CloseableHttpClient httpClient = HttpClients.createDefault();
          HttpPost uploadFile = createHttpPost(this.getSmartsheet().getBaseURI().resolve(url));
  
          try {
              uploadFile.setHeader("Content-Type", "multipart/form-data; boundary=" + boundary);
          } catch (Exception e) {
              throw new RuntimeException(e);
          }
  
          MultipartEntityBuilder builder = MultipartEntityBuilder.create();
          builder.setBoundary(boundary);
          builder.addTextBody(partName, this.getSmartsheet().getJsonSerializer().serialize(t), ContentType.APPLICATION_JSON);
          builder.addBinaryBody("file", inputstream, ContentType.create(contentType), attachmentName);
          org.apache.http.HttpEntity multipart = builder.build();
  
          uploadFile.setEntity(multipart);
  
          try {
              CloseableHttpResponse response = httpClient.execute(uploadFile);
              org.apache.http.HttpEntity responseEntity = response.getEntity();
              attachment = this.getSmartsheet().getJsonSerializer().deserializeResult(Attachment.class,
                      responseEntity.getContent()).getResult();
          }
          catch (Exception e) {
              throw new RuntimeException(e);
          }
          return attachment;
      }
docs: Create a multipart upload request.
  
  @param url the url
  @param t the object to create
  @param partName the name of the part
  @param inputstream the file inputstream
  @param contentType the type of the file to be attached
  @return the http request
  @throws UnsupportedEncodingException the unsupported encoding exception