Show / Hide Table of Contents

Class MultipartBody

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

Inheritance
object
MultipartBody
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public abstract class MultipartBody : DeputyBase
Syntax (vb)
Public MustInherit Class MultipartBody Inherits DeputyBase
Remarks

ExampleMetadata: infused

Examples
var multipartUserData = new MultipartUserData();
            var commandsUserData = UserData.ForLinux();
            multipartUserData.AddUserDataPart(commandsUserData, 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");

Synopsis

Constructors

MultipartBody()

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

Properties

CLOUD_BOOTHOOK

Content type for boot hooks.

SHELL_SCRIPT

Content type for shell scripts.

Methods

FromRawBody(IMultipartBodyOptions)

Constructs the raw MultipartBody using specified body, content type and transfer encoding.

FromUserData(UserData, string?)

Constructs the new MultipartBody wrapping existing UserData. Modification to UserData are reflected in subsequent renders of the part.

RenderBodyPart()

Render body part as the string.

Constructors

MultipartBody()

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

protected MultipartBody()
Remarks

ExampleMetadata: infused

Examples
var multipartUserData = new MultipartUserData();
            var commandsUserData = UserData.ForLinux();
            multipartUserData.AddUserDataPart(commandsUserData, 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");

Properties

CLOUD_BOOTHOOK

Content type for boot hooks.

public static string CLOUD_BOOTHOOK { get; }
Property Value

string

Remarks

ExampleMetadata: infused

SHELL_SCRIPT

Content type for shell scripts.

public static string SHELL_SCRIPT { get; }
Property Value

string

Remarks

ExampleMetadata: infused

Methods

FromRawBody(IMultipartBodyOptions)

Constructs the raw MultipartBody using specified body, content type and transfer encoding.

public static MultipartBody FromRawBody(IMultipartBodyOptions opts)
Parameters
opts IMultipartBodyOptions
Returns

MultipartBody

Remarks

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, string?)

Constructs the new MultipartBody wrapping existing UserData. Modification to UserData are reflected in subsequent renders of the part.

public static MultipartBody FromUserData(UserData userData, string? contentType = null)
Parameters
userData UserData

user data to wrap into body part.

contentType string

optional content type, if default one should not be used.

Returns

MultipartBody

Remarks

For more information about content types see MultipartBodyOptions.contentType.

RenderBodyPart()

Render body part as the string.

public abstract string[] RenderBodyPart()
Returns

string[]

Remarks

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

Back to top Generated by DocFX