Create New File In Amazon S3 Cloud in asp.net c#

Below code use to create or generate new file .txt in Amazon S3 Cloud in asp.net c#.


         public void CreateFileInAmazon()
        {
            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();
                   fileTransferUtility.Upload(stream, "BucketName", "Test.txt");
                }
            }
            catch (AmazonS3Exception s3Exception)
            {
                Console.WriteLine(s3Exception.Message,
                                  s3Exception.InnerException);
            }
        }

Comments

Popular posts from this blog

Convert Html Code to Image JPG PNG in asp.net C#