Chapter 10. Working with Images and Storage
Many applications need to have a way to manage file, image, and video storage. While it’s possible to transform these objects into binary data and store them directly in your database, it’s usually better not to. Instead, using a managed file-hosting service like Amazon S3 is better because it’s less expensive, faster, and just as secure.
In this chapter, we’ll look at how to create a photo-sharing app that renders posts with photos in a stream in real time, allowing you to share an image along with a caption for the image.
Using Amazon S3
Amazon S3 allows you to have secure file hosting that scales as you need it. Amplify uses S3 as the Storage category for handling the storage of files like images, videos, PDFs, and more.
When working with S3, you typically will have three types of file access available:
- Public
-
Items stored with public access will be accessible by all users of your app. These files are stored under the public/ path in your S3 bucket. Public does not mean that anyone with the URL of the resource can view it, though. In order to be viewed, you must use the Amplify SDK to retrieve a temporarily signed URL of the resource. This signed URL will be set to expire after a set period of time (15 minutes by default).
- Private
-
Items are readable by all users, but writable only by the creating user. In S3, the files are stored under the path private/{user_identity_id}, where the user_identity_id corresponds to the unique Amazon ...
Get Full Stack Serverless now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.