I’m using the LitS3 library to help upload photos from my ASP.NET MVC application to Amazon S3.
I’ve read through all the documentation, googled around, and i can’t figure out how to set the cache-control header for the photos when i upload them.
I know you can do it with the REST API, but as i’m using the LitS3 library, that’s not an option (unless i scrap the library altogether).
Has anyone figured out how to do it?
I see the documentation there is a section for “want more flexibility” – which seemingly gives access to nearly 100% of the API, but can’t see how i can apply that to my situation.
Here’s how i’m currently uploading:
var s3 = new S3Service { AccessKeyID = _accessKey, SecretAccessKey = _secret };
s3.AddObject(inputStream,
_bucketName,
fileName,
contentType,
CannedAcl.PublicRead);
Where inputStream is a Stream, that i get from the HttpPostedFileBase.InputStream in my MVC action.
None of the AddObject overloads support setting any other header apart from content-type. So it looks like i need to dig deeper and use a lower-level method, but as i said – just can’t find out how.
Can anyone help?
Got it! Thanks to this thread, which doesn’t concern cache-control, but it shows how to use
AddObjectRequestwith a givenStream.Here’s the working code, if anyone else is interested: