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 content length range condition in an S3 POST policy.
Namespace: Amazon.S3.Model
Assembly: AWSSDK.S3.dll
Version: 3.x.y.z
public class ContentLengthRangeCondition : S3PostCondition
The ContentLengthRangeCondition type exposes the following members
Name | Description | |
---|---|---|
![]() |
ContentLengthRangeCondition(Int64, Int64) |
Initializes a new instance of the Amazon.S3.Model.ContentLengthRangeCondition class. |
Name | Type | Description | |
---|---|---|---|
![]() |
MaximumLength | System.Int64 |
Gets the maximum allowed file size in bytes. |
![]() |
MinimumLength | System.Int64 |
Gets the minimum allowed file size in bytes. |
Name | Description | |
---|---|---|
![]() |
WriteToJsonWriter(Utf8JsonWriter) |
Writes this condition to the specified JSON writer as an array representing the content-length-range condition. |
// Allow files between 1KB and 5MB (typical for profile images) var imageSize = new ContentLengthRangeCondition(1024, 5 * 1024 * 1024); // Allow documents up to 10MB var documentSize = new ContentLengthRangeCondition(0, 10 * 1024 * 1024); // Require non-empty files with reasonable maximum var nonEmptySize = new ContentLengthRangeCondition(1, 100 * 1024 * 1024);
A content length range condition restricts the size of files that can be uploaded through the presigned POST request.
The condition is serialized as a JSON array: ["content-length-range", minimumLength, maximumLength]
Both minimum and maximum values are specified in bytes and are inclusive bounds. The uploaded file size must be greater than or equal to the minimum and less than or equal to the maximum.
Common use cases include:
new ContentLengthRangeCondition(1024, 5 * 1024 * 1024)
(1KB to 5MB)new ContentLengthRangeCondition(0, 10 * 1024 * 1024)
(up to 10MB)new ContentLengthRangeCondition(1, long.MaxValue)
.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