Before getting started Skill Level: Beginner Assumptions: You already gone through Parts 1-7 of Managing Amazon AWS with C#. Additional information: I sometimes cover small sub-topics in a post. Along with AWS, you will also be exposed to: Rhyous.SimpleArgs Don't Repeat Yourself (DRY) Principal Step 1 – Add a DeleteFile method to BucketManager.cs Edit file called BucketManager.cs. Enter this new method: public static async Task CreateTextFile(AmazonS3Client client, string bucketName, string filename, string text) { var dirRequest = new PutObjectRequest { BucketName = bucketName, Key = filename, InputStream = text.ToStream() }; await client.PutObjectAsync(dirRequest); Console.WriteLine($"Created text file in S3 bucket: {bucketName}/{filename}"); } Notice: The code is almost identical to that of deleting a directory, with only one exception. We aren't ending with a /. We really should not have duplicate code. So lets fix this in the next step. Step 2 – Solve the Repetitive Code It is best practice to avoid having duplicate code.
I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
This article is related to
AWS,csharp,aws,c#,S3
AWS,csharp,aws,c#,S3
No comments:
Post a Comment