protected function multipartPart(Array $attributes, $mimetype = null, $contents = null) {
    $multipart = '';
    $headers = [];
    foreach ($attributes as $name => $value) {
      $headers[] = $name . '=' . $value;
    }
    // Generate multipart data and contents.
    $multipart .= '--' . $this->boundary . static::EOL;
    $multipart .= 'Content-Type: ' . $mimetype . static::EOL;
    $multipart .= 'Content-Disposition: form-data; ' . join('; ', $headers) . static::EOL;
    $multipart .= static::EOL . $contents . static::EOL;
    return $multipart;
  }