In this post, I will show you how to read an image from an S3 bucket so that we can attach it to our Tweet.
In S3, create a new bucket called dynamodb-occulttwitterbot-imagestore
In our TwitterBotService project, create a class called S3ImageService and add the following method:
We use the TransferUtility class to open a Stream to the image located in our bucket. We then read this Stream into a MemoryStream instance.
We use the MemoryStream so that we can handle the file in memory, there is no need to save it as a physical file. We simply want to read the file from S3 and upload it straight to Twitter.
In our OccultTwitterBot project, we use the S3ImageService to get our image stream:
The ImageKey is an attribute in our DynamoDb table which holds the name of the image.
<< Selecting a Tweet Table of Contents Deployment >>
No comments:
Post a Comment