Contact Form

Name

Email *

Message *

Cari Blog Ini

Image

Introduction


S3 Browser

Uploading, Downloading, and Deleting Objects from AWS S3

Introduction

Amazon S3 (Simple Storage Service) is a scalable, reliable, and inexpensive storage service offered by Amazon Web Services (AWS). It is designed to store and retrieve any amount of data, including text, images, videos, and other binary files.

To interact with Amazon S3 from your .NET application, you can use the AWS SDK for .NET. The SDK provides a range of classes and methods that make it easy to upload, download, and delete objects from S3.

Code Examples

The following code examples show you how to perform actions and.

  • Upload an object to S3
  • Download an object from S3
  • Delete an object from S3

Uploading an Object to S3

 using Amazon.S3; using Amazon.S3.Model; using System; using System.IO;  public class UploadObjectSample {     public static PutObjectResponse UploadObject(string bucketName, string key, string filePath)     {         using (var client = new AmazonS3Client())         {             var request = new PutObjectRequest             {                 BucketName = bucketName,                 Key = key,                 FilePath = filePath             };              return client.PutObject(request);         }     } } 

Downloading an Object from S3

 using Amazon.S3; using Amazon.S3.Model; using System; using System.IO;  public class DownloadObjectSample {     public static void DownloadObject(string bucketName, string key, string filePath)     {         using (var client = new AmazonS3Client())         {             var request = new GetObjectRequest             {                 BucketName = bucketName,                 Key = key             };              using (var response = client.GetObject(request))             {                 response.WriteResponseStreamToFile(filePath);             }         }     } } 

Deleting an Object from S3

 using Amazon.S3; using Amazon.S3.Model; using System;  public class DeleteObjectSample {     public static void DeleteObject(string bucketName, string key)     {         using (var client = new AmazonS3Client())         {             var request = new DeleteObjectRequest             {                 BucketName = bucketName,                 Key = key             };              client.DeleteObject(request);         }     } } 



Multcloud

Comments