AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
Represents a "starts-with" condition in an S3 POST policy.
Namespace: Amazon.S3.Model
Assembly: AWSSDK.S3.dll
Version: 3.x.y.z
public class StartsWithCondition : S3PostCondition
The StartsWithCondition type exposes the following members
Name | Description | |
---|---|---|
![]() |
StartsWithCondition(string, string) |
Initializes a new instance of the Amazon.S3.Model.StartsWithCondition class. |
Name | Type | Description | |
---|---|---|---|
![]() |
FieldName | System.String |
Gets the name of the form field whose value must start with the specified prefix. |
![]() |
Prefix | System.String |
Gets the prefix that the form field value must start with. |
Name | Description | |
---|---|---|
![]() |
WriteToJsonWriter(Utf8JsonWriter) |
Writes this condition to the specified JSON writer as an array representing the starts-with condition. |
// Only allow uploads to the "user-uploads/" prefix var condition = new StartsWithCondition("key", "user-uploads/"); // Restrict uploads to a specific user's folder var userCondition = new StartsWithCondition("key", $"users/{userId}/"); // Allow uploads with specific metadata prefix var metadataCondition = new StartsWithCondition("x-amz-meta-category", "photo-");
A starts-with condition requires that a form field value begins with the specified prefix. This is particularly useful for restricting object keys to specific prefixes, allowing organized uploads while maintaining flexibility in naming.
The condition is serialized as a JSON array: ["starts-with", "$fieldName", "prefix"]
The field name is automatically prefixed with "$" to indicate it's a variable reference in the POST policy. This is required by the S3 POST policy format.
Common use cases include:
new StartsWithCondition("key", "users/johndoe/")
new StartsWithCondition("key", "images/")
new StartsWithCondition("key", "uploads-2023-")
.NET:
Supported in: 8.0 and newer, Core 3.1
.NET Standard:
Supported in: 2.0
.NET Framework:
Supported in: 4.7.2 and newer