@@ -59,53 +59,6 @@ public async Task<string> CreateBucketAsync(string bucketName)
59
59
return bucketName ;
60
60
}
61
61
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
-
109
62
/// <summary>
110
63
/// Create a presigned POST URL with conditions.
111
64
/// </summary>
@@ -115,6 +68,7 @@ public async Task<CreatePresignedPostResponse> CreatePresignedPostWithFieldsAsyn
115
68
/// <param name="fields">Dictionary of fields to add to the form.</param>
116
69
/// <param name="conditions">List of conditions to apply.</param>
117
70
/// <returns>A CreatePresignedPostResponse object with URL and form fields.</returns>
71
+ // snippet-start:[S3.dotnetv4.CreatePresignedPostAsync]
118
72
public async Task < CreatePresignedPostResponse > CreatePresignedPostWithConditionsAsync (
119
73
string bucketName , string objectKey , DateTime expires ,
120
74
Dictionary < string , string > ? fields = null , List < S3PostCondition > ? conditions = null )
@@ -146,26 +100,7 @@ public async Task<CreatePresignedPostResponse> CreatePresignedPostWithConditions
146
100
147
101
return await _s3Client . CreatePresignedPostAsync ( request ) ;
148
102
}
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]
169
104
170
105
/// <summary>
171
106
/// Delete an object from an S3 bucket.
@@ -222,35 +157,4 @@ public async Task<GetObjectMetadataResponse> GetObjectMetadataAsync(
222
157
223
158
return await _s3Client . GetObjectMetadataAsync ( request ) ;
224
159
}
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
- }
256
160
}
0 commit comments