# MultipartBody

The base class for all classes which can be used as `MultipartUserData`.

- Source: [`aws-ec2/lib/user-data.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-ec2/lib/user-data.ts#L339)

## Example

```ts
const multipartUserData = new ec2.MultipartUserData();
const commandsUserData = ec2.UserData.forLinux();
multipartUserData.addUserDataPart(commandsUserData, ec2.MultipartBody.SHELL_SCRIPT, true);

// Adding commands to the multipartUserData adds them to commandsUserData, and vice-versa.
multipartUserData.addCommands('touch /root/multi.txt');
commandsUserData.addCommands('touch /root/userdata.txt');
```

## Initializer

```ts
new MultipartBody()
```

## Properties

- `CLOUD_BOOTHOOK`: string (required) (static) — Content type for boot hooks.

- `SHELL_SCRIPT`: string (required) (static) — Content type for shell scripts.

## Methods

- `fromRawBody(opts: MultipartBodyOptions): MultipartBody // chainable` (static) — Constructs the raw `MultipartBody` using specified body, content type and transfer encoding.

  When transfer encoding is specified (typically as Base64), it's caller responsibility to convert body to
  Base64 either by wrapping with `Fn.base64` or by converting it by other converters.

- `fromUserData(userData: UserData, contentType?: string): MultipartBody // chainable` (static) — Constructs the new `MultipartBody` wrapping existing `UserData`. Modification to `UserData` are reflected in subsequent renders of the part.

  For more information about content types see `MultipartBodyOptions.contentType`.

  **Parameters**

  - `userData` — user data to wrap into body part.
  - `contentType` — optional content type, if default one should not be used.

- `renderBodyPart(): string[]` — Render body part as the string.

  Subclasses should not add leading nor trailing new line characters (\r \n)
