Skip to content

Commit 7408acb

Browse files
committed
update metadata
1 parent 6cee667 commit 7408acb

File tree

3 files changed

+7
-100
lines changed

3 files changed

+7
-100
lines changed

.doc_gen/metadata/s3_metadata.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3713,7 +3713,10 @@ s3_CreatePresignedPost:
37133713
- sdk_version: 4
37143714
github: dotnetv4/S3
37153715
excerpts:
3716-
- description:
3716+
- description: Create a presigned POST URL with conditions
3717+
snippet_tags:
3718+
- S3.dotnetv4.CreatePresignedPostAsync
3719+
- description: Example using presigned POST
37173720
snippet_tags:
37183721
- S3.dotnetv4.CreatePresignedPost
37193722
services:

dotnetv4/S3/Actions/S3Wrapper.cs

Lines changed: 2 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -59,53 +59,6 @@ public async Task<string> CreateBucketAsync(string bucketName)
5959
return bucketName;
6060
}
6161

62-
/// <summary>
63-
/// Create a presigned POST URL for uploading a file to an S3 bucket.
64-
/// </summary>
65-
/// <param name="bucketName">The name of the bucket.</param>
66-
/// <param name="objectKey">The object key (path) where the uploaded file will be stored.</param>
67-
/// <param name="expires">When the presigned URL expires.</param>
68-
/// <returns>A CreatePresignedPostResponse object with URL and form fields.</returns>
69-
public async Task<CreatePresignedPostResponse> CreatePresignedPostAsync(
70-
string bucketName, string objectKey, DateTime expires)
71-
{
72-
var request = new CreatePresignedPostRequest
73-
{
74-
BucketName = bucketName,
75-
Key = objectKey,
76-
Expires = expires
77-
};
78-
79-
return await _s3Client.CreatePresignedPostAsync(request);
80-
}
81-
82-
/// <summary>
83-
/// Create a presigned POST URL with custom fields.
84-
/// </summary>
85-
/// <param name="bucketName">The name of the bucket.</param>
86-
/// <param name="objectKey">The object key (path) where the uploaded file will be stored.</param>
87-
/// <param name="expires">When the presigned URL expires.</param>
88-
/// <param name="fields">Dictionary of fields to add to the form.</param>
89-
/// <returns>A CreatePresignedPostResponse object with URL and form fields.</returns>
90-
public async Task<CreatePresignedPostResponse> CreatePresignedPostWithFieldsAsync(
91-
string bucketName, string objectKey, DateTime expires, Dictionary<string, string> fields)
92-
{
93-
var request = new CreatePresignedPostRequest
94-
{
95-
BucketName = bucketName,
96-
Key = objectKey,
97-
Expires = expires
98-
};
99-
100-
// Add custom fields
101-
foreach (var field in fields)
102-
{
103-
request.Fields.Add(field.Key, field.Value);
104-
}
105-
106-
return await _s3Client.CreatePresignedPostAsync(request);
107-
}
108-
10962
/// <summary>
11063
/// Create a presigned POST URL with conditions.
11164
/// </summary>
@@ -115,6 +68,7 @@ public async Task<CreatePresignedPostResponse> CreatePresignedPostWithFieldsAsyn
11568
/// <param name="fields">Dictionary of fields to add to the form.</param>
11669
/// <param name="conditions">List of conditions to apply.</param>
11770
/// <returns>A CreatePresignedPostResponse object with URL and form fields.</returns>
71+
// snippet-start:[S3.dotnetv4.CreatePresignedPostAsync]
11872
public async Task<CreatePresignedPostResponse> CreatePresignedPostWithConditionsAsync(
11973
string bucketName, string objectKey, DateTime expires,
12074
Dictionary<string, string>? fields = null, List<S3PostCondition>? conditions = null)
@@ -146,26 +100,7 @@ public async Task<CreatePresignedPostResponse> CreatePresignedPostWithConditions
146100

147101
return await _s3Client.CreatePresignedPostAsync(request);
148102
}
149-
150-
/// <summary>
151-
/// Upload a file to an S3 bucket.
152-
/// </summary>
153-
/// <param name="bucketName">The name of the bucket.</param>
154-
/// <param name="objectKey">The object key where the file will be stored.</param>
155-
/// <param name="filePath">The path to the file to upload.</param>
156-
/// <returns>The response from the PutObjectAsync call.</returns>
157-
public async Task<PutObjectResponse> UploadFileAsync(
158-
string bucketName, string objectKey, string filePath)
159-
{
160-
var request = new PutObjectRequest
161-
{
162-
BucketName = bucketName,
163-
Key = objectKey,
164-
FilePath = filePath
165-
};
166-
167-
return await _s3Client.PutObjectAsync(request);
168-
}
103+
// snippet-end:[S3.dotnetv4.CreatePresignedPostAsync]
169104

170105
/// <summary>
171106
/// Delete an object from an S3 bucket.
@@ -222,35 +157,4 @@ public async Task<GetObjectMetadataResponse> GetObjectMetadataAsync(
222157

223158
return await _s3Client.GetObjectMetadataAsync(request);
224159
}
225-
226-
/// <summary>
227-
/// Get an object from an S3 bucket.
228-
/// </summary>
229-
/// <param name="bucketName">The name of the bucket.</param>
230-
/// <param name="objectKey">The object key.</param>
231-
/// <returns>The response from the GetObjectAsync call.</returns>
232-
public async Task<GetObjectResponse> GetObjectAsync(
233-
string bucketName, string objectKey)
234-
{
235-
var request = new GetObjectRequest
236-
{
237-
BucketName = bucketName,
238-
Key = objectKey
239-
};
240-
241-
return await _s3Client.GetObjectAsync(request);
242-
}
243-
244-
/// <summary>
245-
/// Read the content of an S3 object as a string.
246-
/// </summary>
247-
/// <param name="bucketName">The name of the bucket.</param>
248-
/// <param name="objectKey">The object key.</param>
249-
/// <returns>The object content as a string.</returns>
250-
public async Task<string> ReadObjectContentAsync(string bucketName, string objectKey)
251-
{
252-
var response = await GetObjectAsync(bucketName, objectKey);
253-
using var reader = new StreamReader(response.ResponseStream);
254-
return await reader.ReadToEndAsync();
255-
}
256160
}

dotnetv4/S3/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ For prerequisites, see the [README](../README.md#Prerequisites) in the `dotnetv4
3333

3434
Code excerpts that show you how to call individual service functions.
3535

36-
- [CreatePresignedPost](Actions/CreatePresignedPost.cs#L6)
36+
- [CreatePresignedPost](Actions/S3Wrapper.cs#L71)
3737

3838
### Scenarios
3939

0 commit comments

Comments
 (0)