· 6 years ago · Feb 26, 2019, 09:28 AM
1using (var client = AWSClientFactory.CreateAmazonS3Client(accessKey, secretKey, s3Config))
2 {
3 var request = new PutObjectRequest()
4 .WithBucketName(bucketName)
5 .WithKey(fileKey)
6 .WithMetaData("title", title);
7 request.ContentBody = body;
8 S3Response response = client.PutObject(request);
9 response.Dispose();
10 }
11
12private static string HtmlEncodeSpecialChars(string html)
13 {
14 var sb = new StringBuilder();
15 foreach (var c in html)
16 {
17 if (c > 127) // special chars
18 sb.Append(String.Format("&#{0};", (int)c));
19 else
20 sb.Append(c);
21 }
22 return sb.ToString();
23 }