Load file from Amazon S3 storage
Leave feedback
The following code snippet shows how to convert a file from Amazon S3 Storage:
public static void Run()
{
string key = "sample.docx";
string outputFile = Path.Combine("c:\output" , "converted.pdf");
using (Converter converter = new Converter(() => DownloadFile(key)))
{
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert(outputFile, options);
}
}
public static Stream DownloadFile(string key)
{
AmazonS3Client client = new AmazonS3Client();
string bucketName = "my-bucket";
GetObjectRequest request = new GetObjectRequest
{
Key = key,
BucketName = bucketName
};
using (GetObjectResponse response = client.GetObject(request))
{
MemoryStream stream = new MemoryStream();
response.ResponseStream.CopyTo(stream);
stream.Position = 0;
return stream;
}
}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.