protected void writeFileMetadata(
      Output output, String name, String fileName, String contentType) {
    val contentDespositionBuilder =
        new StringBuilder()
            .append("Content-Disposition: form-data; name=\"")
            .append(name)
            .append("\"");
    if (fileName != null) {
      contentDespositionBuilder.append("; ").append("filename=\"").append(fileName).append("\"");
    }

    String fileContentType = contentType;
    if (fileContentType == null) {
      if (fileName != null) {
        fileContentType = URLConnection.guessContentTypeFromName(fileName);
      }
      if (fileContentType == null) {
        fileContentType = "application/octet-stream";
      }
    }

    val string =
        new StringBuilder()
            .append(contentDespositionBuilder.toString())
            .append(CRLF)
            .append("Content-Type: ")
            .append(fileContentType)
            .append(CRLF)
            .append("Content-Transfer-Encoding: binary")
            .append(CRLF)
            .append(CRLF)
            .toString();

    output.write(string);
  }
Writes file's metadata.

@param output output writer.
@param name name for piece of data.
@param fileName file name.
@param contentType type of file content. May be the {@code null}, in that case it will be
    determined by file name.
form/src/main/java/feign/form/multipart/AbstractWriter.java