Write Content in file in Amazon S3 Cloud asp.net c#
Use this code to write content in asp.net c# in Amazon S3 Cloud
public void WriteContentInFile()
{
try
{
AWSCredentials credentials = new BasicAWSCredentials("Accesskey", "secretkey");
AmazonS3Config config = new AmazonS3Config();
config.ServiceURL = "s3.amazonaws.com";
config.RegionEndpoint = Amazon.RegionEndpoint.GetBySystemName("ap-south-1");
AmazonS3Client client;
using (client = new AmazonS3Client(credentials, config))
{
TransferUtility fileTransferUtility = new
TransferUtility(client);
Stream stream = new MemoryStream();
string BucketName = "BucketName";
PutObjectRequest putRequest1 = new PutObjectRequest
{
BucketName = BucketName,
Key = "Text.txt",
ContentBody = "Your Content"
};
PutObjectResponse response1 = client.PutObject(putRequest1);
}
}
catch (AmazonS3Exception s3Exception)
{
Console.WriteLine(s3Exception.Message,
s3Exception.InnerException);
}
}
Comments
Post a Comment