I have a text file on my amazon s3 bucket and I want to write some text at the end of that file. Something like following : xxxxxx|xxxxxx|xxxxx|xxxx. I want to do this with c#. I did tried using streamwriter but it did not worked.
using(StreamWriter writer = new StreamWriter(Server.MapPath(url), true))
{
writer.WriteLine("xxxxxxxx|xxxxxxxxxxx|xxxxxxx|xxxxxxxxxx");
}
My initial guess is that there must be some kind of authentication requirements. Can anyone help me out or direct to appropriate resources.
You can use the Object. put() method available in the S3 object. It allows two ways to write into the S3.
Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/ . In the Buckets list, choose the name of the bucket that you want to upload your folders or files to. Choose Upload.
Amazon S3 doesn't support appending to objects. You would have to read the entire object from S3, then put it back again with the new data.
The AWS SDK for .NET (See http://aws.amazon.com/sdkfornet ) provides tools that will make authenticated S3 operations easier to manage in C#, including treating S3 buckets like a local filesystem (See http://docs.amazonwebservices.com/sdkfornet/latest/apidocs/html/N_Amazon_S3_IO.htm)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With