Amazon S3 Bucket Management with C#: Part 9 – Uploading a file with its path to a Bucket - Online Free Computer Tutorials.

'Software Development, Games Development, Mobile Development, iOS Development, Android Development, Window Phone Development. Dot Net, Window Services,WCF Services, Web Services, MVC, MySQL, SQL Server and Oracle Tutorials, Articles and their Resources

Tuesday, August 7, 2018

Amazon S3 Bucket Management with C#: Part 9 – Uploading a file with its path to a Bucket

Before getting started Skill Level: Beginner Assumptions: You already gone through Parts 1-8 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 Step 1 – Alter the existing UploadFile method in BucketManager.cs We need the UploadFile method to take in a parameter that specifies the remote directory, which is the directory path on the S3 bucket. However, if no directory is specified, the key should simply be the file name. Edit file called BucketManager.cs. Enter this new method: Note: We are in luck, the TransferUtility object has an overload that takes in the key. public static async Task UploadFile(TransferUtility transferUtility, string bucketName, string file, string uploadLocation = null) { var key = Path.GetFileName(file); if (!string.IsNullOrWhiteSpace(uploadLocation)) { uploadLocation = uploadLocation.EndsWith("/") ? uploadLocation : uploadLocation + "/"; key = uploadLocation + key; } await Task.


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 blogtwitter 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

No comments:

Post a Comment