What you’ll learn
  • how file downloads are handled by the deployed cloud infrastructure and application code

Diagram
anchor

For brevity, the diagram doesn’t include network-level cloud infrastructure resources, like region, VPC, availability zones, and so on. Check out the Deployment Modes section if you’re interested in that aspect of the deployed cloud infrastructure.
Note that the stateful resources like Amazon S3, Amazon Cognito, Amazon DynamoDB and Amazon ElasticSearch are deployed as part of the Core project application. These are still included in the diagram, just so it’s more clear to the reader.
Webiny Cloud Infrastructure - API - File DownloadWebiny Cloud Infrastructure - API - File Download
(click to enlarge)

Description
anchor

The diagram shows what happens every time a client tries to download a binary file.

The flow consists of the following four steps:

  1. The client issues a GET /download/{file-key} HTTP request, which reaches the Amazon API Gateway B, which then invokes the File Manager’s Download AWS Lambda function H4.
  2. The Download AWS Lambda function extracts the file key from the received HTTP request, and then fetches the file from the S3 bucket H1.
  3. As a base64 encoded string, the file is returned to the Amazon API Gateway B, which transforms it to an actual binary, and sends it back to the Amazon CloudFront A.
  4. Amazon CloudFront A receives the file, caches it, and sends it back to the client.

Visit the Working with binary media types for REST APIs external link article to learn more about how Amazon API Gateway deals with binary files.