AWS SDK Version 4 for .NET
API Reference

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.

Creates a starts-with condition that requires a form field value to begin with the specified prefix.

Namespace: Amazon.S3.Model
Assembly: AWSSDK.S3.dll
Version: 3.x.y.z

Syntax

C#
public StartsWithCondition StartsWith(
         String fieldName,
         String prefix
)

Parameters

fieldName
Type: System.String

The name of the form field whose value must start with the specified prefix. The most common field is "key" for restricting object key prefixes, but any form field can be used.

prefix
Type: System.String

The prefix that the form field value must start with. Can be an empty string to allow any value (though this makes the condition effectively permissive).

Return Value


A for the specified field and prefix.

Exceptions

ExceptionCondition
System.ArgumentNullException Thrown when or is null.
System.ArgumentException Thrown when is empty.

Examples

// Only allow uploads to the "user-uploads/" prefix
var keyCondition = S3PostCondition.StartsWith("key", "user-uploads/");
            
// Restrict uploads to a specific user's folder
var userCondition = S3PostCondition.StartsWith("key", $"users/{userId}/");
            

Version Information

.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