Skip to content

Commit f084f15

Browse files
Dotnetv4: Add CreatePresignedPost in S3 (#7536)
* Add CreatePresignedPost examples for dotnetv4
1 parent 9092c28 commit f084f15

File tree

13 files changed

+862
-3
lines changed

13 files changed

+862
-3
lines changed

.doc_gen/metadata/s3_metadata.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2776,6 +2776,12 @@ s3_Scenario_PresignedUrl:
27762776
- description: Generate a presigned URL and perform an upload using that URL.
27772777
snippet_tags:
27782778
- S3.dotnetv3.UploadUsingPresignedURLExample
2779+
- sdk_version: 4
2780+
github: dotnetv4/S3/Scenarios/S3_CreatePresignedPost
2781+
excerpts:
2782+
- description: Create and use presigned POST URLs for direct browser uploads.
2783+
snippet_tags:
2784+
- S3.dotnetv4.CreatePresignedPostBasics
27792785
Java:
27802786
versions:
27812787
- sdk_version: 2
@@ -3705,3 +3711,17 @@ s3_Scenario_DoesBucketExist:
37053711
- s3.java2.does-bucket-exist-main
37063712
services:
37073713
s3: {GetBucketAcl}
3714+
3715+
s3_CreatePresignedPost:
3716+
languages:
3717+
.NET:
3718+
versions:
3719+
- sdk_version: 4
3720+
github: dotnetv4/S3
3721+
excerpts:
3722+
- description: Create a presigned POST URL.
3723+
genai: most
3724+
snippet_tags:
3725+
- S3.dotnetv4.Scenario_CreatePresignedPostAsync
3726+
services:
3727+
s3: {CreatePresignedPost}

dotnetv4/Bedrock-runtime/Actions/HelloBedrockRuntime.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ private static async Task Invoke(string modelId, string prompt)
2828
default:
2929
Console.WriteLine($"Unknown model ID: {modelId}. Valid model IDs are: {CLAUDE}.");
3030
break;
31-
};
31+
}
32+
;
3233
}
3334
}
3435
}

dotnetv4/DotNetV4Examples.sln

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basics", "DynamoDB\Scenario
149149
EndProject
150150
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamoDBActions", "DynamoDB\Actions\DynamoDBActions.csproj", "{B0F91FE2-6AC5-4FA8-B321-54623A516D4D}"
151151
EndProject
152-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scenarios", "Scenarios", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
152+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "S3", "S3", "{F929DB74-DD0E-B0EF-AA66-D8703D547BBD}"
153+
EndProject
154+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "S3Tests", "S3\Tests\S3Tests.csproj", "{11497EB7-B702-B537-3CBE-BA2F4F85F313}"
155+
EndProject
156+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scenarios", "Scenarios", "{A65C33EA-4F2E-DE85-7501-4389A2100813}"
157+
EndProject
158+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basics", "S3\Scenarios\S3_CreatePresignedPost\Basics.csproj", "{2B6F24A0-4569-E8A2-81B4-3925FA4F0320}"
153159
EndProject
154160
Global
155161
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -365,6 +371,14 @@ Global
365371
{B0F91FE2-6AC5-4FA8-B321-54623A516D4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
366372
{B0F91FE2-6AC5-4FA8-B321-54623A516D4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
367373
{B0F91FE2-6AC5-4FA8-B321-54623A516D4D}.Release|Any CPU.Build.0 = Release|Any CPU
374+
{11497EB7-B702-B537-3CBE-BA2F4F85F313}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
375+
{11497EB7-B702-B537-3CBE-BA2F4F85F313}.Debug|Any CPU.Build.0 = Debug|Any CPU
376+
{11497EB7-B702-B537-3CBE-BA2F4F85F313}.Release|Any CPU.ActiveCfg = Release|Any CPU
377+
{11497EB7-B702-B537-3CBE-BA2F4F85F313}.Release|Any CPU.Build.0 = Release|Any CPU
378+
{2B6F24A0-4569-E8A2-81B4-3925FA4F0320}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
379+
{2B6F24A0-4569-E8A2-81B4-3925FA4F0320}.Debug|Any CPU.Build.0 = Debug|Any CPU
380+
{2B6F24A0-4569-E8A2-81B4-3925FA4F0320}.Release|Any CPU.ActiveCfg = Release|Any CPU
381+
{2B6F24A0-4569-E8A2-81B4-3925FA4F0320}.Release|Any CPU.Build.0 = Release|Any CPU
368382
EndGlobalSection
369383
GlobalSection(SolutionProperties) = preSolution
370384
HideSolutionNode = FALSE
@@ -425,14 +439,17 @@ Global
425439
{3F159C49-3DE7-42F5-AF14-E64C03AF19E8} = {EE6D1933-1E38-406A-B691-446326310D1F}
426440
{D44D50E1-EC65-4A1C-AAA1-C360E4FC563F} = {EE6D1933-1E38-406A-B691-446326310D1F}
427441
{7485EAED-F81C-4119-BABC-E009A21ACE46} = {EE6D1933-1E38-406A-B691-446326310D1F}
442+
{02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}
428443
{43C5E98B-5EC4-9F2B-2676-8F1E34969855} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
429444
{6BE1D9A4-1832-49F5-8682-6DEE4A7D6232} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
430445
{6B1F00FF-7F1D-C5D8-A8D3-E0EF2886B8C6} = {6BE1D9A4-1832-49F5-8682-6DEE4A7D6232}
431446
{9D601495-FDBA-C852-4ACB-EC54EDC9B3E5} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
432447
{F578CA07-E74F-4F47-9203-C67777D9BB78} = {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}
433448
{E10920BB-6409-41BB-9A9D-813BC37CC3C0} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
434449
{B0F91FE2-6AC5-4FA8-B321-54623A516D4D} = {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}
435-
{02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}
450+
{11497EB7-B702-B537-3CBE-BA2F4F85F313} = {F929DB74-DD0E-B0EF-AA66-D8703D547BBD}
451+
{A65C33EA-4F2E-DE85-7501-4389A2100813} = {F929DB74-DD0E-B0EF-AA66-D8703D547BBD}
452+
{2B6F24A0-4569-E8A2-81B4-3925FA4F0320} = {A65C33EA-4F2E-DE85-7501-4389A2100813}
436453
EndGlobalSection
437454
GlobalSection(ExtensibilityGlobals) = postSolution
438455
SolutionGuid = {08502818-E8E1-4A91-A51C-4C8C8D4FF9CA}

dotnetv4/S3/README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Amazon S3 code examples for the SDK for .NET (v4)
2+
3+
## Overview
4+
5+
Shows how to use the AWS SDK for .NET (v4) to work with Amazon Simple Storage Service (Amazon S3).
6+
7+
<!--custom.overview.start-->
8+
<!--custom.overview.end-->
9+
10+
_Amazon S3 is storage for the internet. You can use Amazon S3 to store and retrieve any amount of data at any time, from anywhere on the web._
11+
12+
## ⚠ Important
13+
14+
* Running this code might result in charges to your AWS account. For more details, see [AWS Pricing](https://aws.amazon.com/pricing/) and [Free Tier](https://aws.amazon.com/free/).
15+
* Running the tests might result in charges to your AWS account.
16+
* We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege).
17+
* This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services).
18+
19+
<!--custom.important.start-->
20+
<!--custom.important.end-->
21+
22+
## Code examples
23+
24+
### Prerequisites
25+
26+
For prerequisites, see the [README](../README.md#Prerequisites) in the `dotnetv4` folder.
27+
28+
29+
<!--custom.prerequisites.start-->
30+
<!--custom.prerequisites.end-->
31+
32+
### Single actions
33+
34+
Code excerpts that show you how to call individual service functions.
35+
36+
- [CreatePresignedPost](Scenarios/S3_CreatePresignedPost/S3Wrapper.cs#L35)
37+
38+
### Scenarios
39+
40+
Code examples that show you how to accomplish a specific task by calling multiple
41+
functions within the same service.
42+
43+
- [Create a presigned URL](Scenarios/S3_CreatePresignedPost/CreatePresignedPostBasics.cs)
44+
45+
46+
<!--custom.examples.start-->
47+
<!--custom.examples.end-->
48+
49+
## Run the examples
50+
51+
### Instructions
52+
53+
54+
<!--custom.instructions.start-->
55+
<!--custom.instructions.end-->
56+
57+
58+
59+
#### Create a presigned URL
60+
61+
This example shows you how to create a presigned URL for Amazon S3 and upload an object.
62+
63+
64+
<!--custom.scenario_prereqs.s3_Scenario_PresignedUrl.start-->
65+
<!--custom.scenario_prereqs.s3_Scenario_PresignedUrl.end-->
66+
67+
68+
<!--custom.scenarios.s3_Scenario_PresignedUrl.start-->
69+
<!--custom.scenarios.s3_Scenario_PresignedUrl.end-->
70+
71+
### Tests
72+
73+
⚠ Running tests might result in charges to your AWS account.
74+
75+
76+
To find instructions for running these tests, see the [README](../README.md#Tests)
77+
in the `dotnetv4` folder.
78+
79+
80+
81+
<!--custom.tests.start-->
82+
<!--custom.tests.end-->
83+
84+
## Additional resources
85+
86+
- [Amazon S3 User Guide](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html)
87+
- [Amazon S3 API Reference](https://docs.aws.amazon.com/AmazonS3/latest/API/Welcome.html)
88+
- [SDK for .NET (v4) Amazon S3 reference](https://docs.aws.amazon.com/sdkfornet/v4/apidocs/items/S3/NS3.html)
89+
90+
<!--custom.resources.start-->
91+
<!--custom.resources.end-->
92+
93+
---
94+
95+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
96+
97+
SPDX-License-Identifier: Apache-2.0

dotnetv4/S3/S3Examples.sln

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.5.33414.496
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scenarios", "Scenarios", "{C13DDD1A-438D-4E52-90FB-A496A54516C7}"
6+
EndProject
7+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{C51625C8-3B42-4810-BF1B-0E3C6C716FA6}"
8+
EndProject
9+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basics", "Scenarios\S3_CreatePresignedPost\Basics.csproj", "{22C217CC-E2D9-9F79-EE15-24F9D262655E}"
10+
EndProject
11+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "S3Tests", "Tests\S3Tests.csproj", "{FB41CEEB-5F32-3E4A-F9C6-1FACCBDAFF3C}"
12+
EndProject
13+
Global
14+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
15+
Debug|Any CPU = Debug|Any CPU
16+
Release|Any CPU = Release|Any CPU
17+
EndGlobalSection
18+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
19+
{22C217CC-E2D9-9F79-EE15-24F9D262655E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20+
{22C217CC-E2D9-9F79-EE15-24F9D262655E}.Debug|Any CPU.Build.0 = Debug|Any CPU
21+
{22C217CC-E2D9-9F79-EE15-24F9D262655E}.Release|Any CPU.ActiveCfg = Release|Any CPU
22+
{22C217CC-E2D9-9F79-EE15-24F9D262655E}.Release|Any CPU.Build.0 = Release|Any CPU
23+
{FB41CEEB-5F32-3E4A-F9C6-1FACCBDAFF3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24+
{FB41CEEB-5F32-3E4A-F9C6-1FACCBDAFF3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
25+
{FB41CEEB-5F32-3E4A-F9C6-1FACCBDAFF3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
26+
{FB41CEEB-5F32-3E4A-F9C6-1FACCBDAFF3C}.Release|Any CPU.Build.0 = Release|Any CPU
27+
EndGlobalSection
28+
GlobalSection(SolutionProperties) = preSolution
29+
HideSolutionNode = FALSE
30+
EndGlobalSection
31+
GlobalSection(NestedProjects) = preSolution
32+
{22C217CC-E2D9-9F79-EE15-24F9D262655E} = {C13DDD1A-438D-4E52-90FB-A496A54516C7}
33+
{FB41CEEB-5F32-3E4A-F9C6-1FACCBDAFF3C} = {C51625C8-3B42-4810-BF1B-0E3C6C716FA6}
34+
EndGlobalSection
35+
GlobalSection(ExtensibilityGlobals) = postSolution
36+
SolutionGuid = {5ACB5B08-E8F8-453C-B63B-6C0C9DE67780}
37+
EndGlobalSection
38+
EndGlobal
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="AWSSDK.S3" Version="4.0.6.1" />
12+
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="4.0.2" />
13+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
14+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
15+
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.0" />
16+
</ItemGroup>
17+
18+
</Project>

0 commit comments

Comments
 (0)