Pipeline Pipeline - 1 year ago 66
C# Question

Write directly to Amazon S3

I am reading Amazon S3 documentation, but I am bit lost...

Actually, user upload a file to Amazon S3, then, I copy it to EC2, proccess it, back to S3 and user can download it.

When I proccess the file, I need to create a html file, and I need to create in Amazon S3, but I don't know how can I create this file directly on S3. Right now, I create a file on EC2 and then I move it to S3.

To create this html y use:

TextWriter tw = new StreamWriter(pathFile);

Where page is a string with html code, and pathFile is:
string outputWap = Server.MapPath("~/xxx.html");

I'm using ASP.NET MVC 2.

Thanks for your help.


Answer Source

If you are using the AWS SDK for .Net you could try using PutObjectRequest with the InputStream set instead of FilePath although I haven't tried this myself.

Otherwise I don't really see what's wrong with the way you are currently doing it anyway.