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 content length range condition that restricts file size to the specified byte range.

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

Syntax

C#
public ContentLengthRangeCondition ContentLengthRange(
         Int64 minimumLength,
         Int64 maximumLength
)

Parameters

minimumLength
Type: System.Int64

The minimum allowed file size in bytes. Must be non-negative. Use 0 to allow empty files, or 1 to require non-empty files.

maximumLength
Type: System.Int64

The maximum allowed file size in bytes. Must be greater than or equal to the minimum length.

Return Value


A for the specified size range.

Exceptions

ExceptionCondition
System.ArgumentException Thrown when is negative, or when is less than .

Examples

// Allow files between 1KB and 5MB
var sizeCondition = S3PostCondition.ContentLengthRange(1024, 5 * 1024 * 1024);
            
// Allow documents up to 10MB
var docSizeCondition = S3PostCondition.ContentLengthRange(0, 10 * 1024 * 1024);
            

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