Downloading and saving images to S3
We have seen how to write content into S3 in Chapter 3, Processing Data. Here we will extend that process into an interface implementation of IBlobWriter to write to S3.
Getting ready
The code example for this recipe is in the 04/06_save_image_in_s3.py
file. Also ensure that you have set your AWS keys as environment variables so that Boto can authenticate the script.
How to do it
We proceed as follows:
- Run the recipe's script. It will execute the following:
# download the image item = URLUtility(const.ApodEclipseImage()) # store it in S3 S3BlobWriter(bucket_name="scraping-apod").write(item.filename, item.data)
- Checking in S3, we can see that the bucket was created and the image placed within the bucket:

The Image in S3
How it works
The following is the implementation of the S3BlobWriter
:
class S3BlobWriter(implements(IBlobWriter)): def __init__(self, bucket_name, boto_client=None): self._bucket_name = bucket_name if self._bucket_name is None...