Snowcode.S3BuildPublisher.S3.S3Helper.PutTextObject C# (CSharp) Method

PutTextObject() public method

Creates a text object in the S3 bucket.
public PutTextObject ( string bucketName, string key, string text ) : void
bucketName string
key string
text string
return void
        public void PutTextObject(string bucketName, string key, string text)
        {
            var request = new PutObjectRequest
                              {
                                  ContentType = "text/html",
                                  ContentBody = text,
                                  BucketName = bucketName,
                                  Key = key
                              };

            Client.PutObject(request);
        }

Usage Example

        public void DeleteObject_Should_Succeed()
        {
            // Get the client details from the stored client details (rather than embed secret keys in the test).
            // Ensure that your AWS/Secret keys have been stored before running.
            var store = new ClientDetailsStore();
            AwsClientDetails clientDetails = store.Load(Container);

            S3Helper helper = new S3Helper(clientDetails);

            const string bucketName = "ExampleTestBucket";
            const string key = "ExampleObject";

            // Put a simple text object into the bucket to delete.
            helper.CreateBucket(bucketName);
            helper.PutTextObject(bucketName, key, "Example text to store in the object");

            try
            {
                helper.DeleteObject(bucketName, key);
            }
            finally
            {
                helper.DeleteBucket(bucketName);
            }
        }
All Usage Examples Of Snowcode.S3BuildPublisher.S3.S3Helper::PutTextObject