3
3
4
4
namespace S3Scenarios ;
5
5
6
- // snippet-start:[S3.dotnetv4.CreatePresignedPostScenario ]
6
+ // snippet-start:[S3.dotnetv4.CreatePresignedPostBasics ]
7
7
/// <summary>
8
8
/// Scenario demonstrating the complete workflow for presigned POST URLs:
9
9
/// 1. Create an S3 bucket
10
10
/// 2. Create a presigned POST URL
11
11
/// 3. Upload a file using the presigned POST URL
12
12
/// 4. Clean up resources
13
13
/// </summary>
14
- public class CreatePresignedPostScenario
14
+ public class CreatePresignedPostBasics
15
15
{
16
16
private readonly S3Wrapper _s3Wrapper ;
17
17
private readonly ILogger _logger ;
@@ -27,7 +27,7 @@ public class CreatePresignedPostScenario
27
27
/// <param name="logger">The logger to use.</param>
28
28
/// <param name="uiMethods">The UI methods to use.</param>
29
29
/// <param name="isInteractive">Whether to run in interactive mode.</param>
30
- public CreatePresignedPostScenario ( S3Wrapper s3Wrapper , ILogger logger , UiMethods uiMethods , bool isInteractive )
30
+ public CreatePresignedPostBasics ( S3Wrapper s3Wrapper , ILogger logger , UiMethods uiMethods , bool isInteractive )
31
31
{
32
32
_s3Wrapper = s3Wrapper ;
33
33
_logger = logger ;
@@ -120,7 +120,7 @@ private async Task<CreatePresignedPostResponse> CreatePresignedPostAsync()
120
120
Console . WriteLine ( $ "Creating presigned POST URL for { _bucketName } /{ _objectKey } ") ;
121
121
Console . WriteLine ( $ "Expiration: { expiration } UTC") ;
122
122
123
- var response = await _s3Wrapper . CreatePresignedPostAsync ( _bucketName ! , _objectKey , expiration ) ;
123
+ var response = await _s3Wrapper . CreatePresignedPostWithConditionsAsync ( _bucketName ! , _objectKey , expiration ) ;
124
124
125
125
Console . WriteLine ( "Successfully created presigned POST URL" ) ;
126
126
return response ;
@@ -251,5 +251,16 @@ private async Task CleanupAsync()
251
251
}
252
252
}
253
253
}
254
+
255
+ public static void DisplayPresignedPostFields ( CreatePresignedPostResponse response )
256
+ {
257
+ Console . WriteLine ( $ "Presigned POST URL: { response . Url } ") ;
258
+ Console . WriteLine ( "Form fields to include:" ) ;
259
+
260
+ foreach ( var field in response . Fields )
261
+ {
262
+ Console . WriteLine ( $ " { field . Key } : { field . Value } ") ;
263
+ }
264
+ }
254
265
}
255
- // snippet-end:[S3.dotnetv4.CreatePresignedPostScenario ]
266
+ // snippet-end:[S3.dotnetv4.CreatePresignedPostBasics ]
0 commit comments