With the setup done, we can now focus on the application code. Let's take a look at the uploadImage function, as that is the gateway to the entire process.
We first need to initialize our two dependencies at the top of this handler.js file, as follows:
- The aws-sdk, which is automatically available in the Lambda runtime
- The jimp library for doing the image manipulation
Going from the top down, our uploadImage function defines a few things. First, our params object contains the base of the Lamda invocation parameters. Note here that we're using an InvocationType of "Event", which is extremely important in order to get the asynchronous fan-out described earlier. Next, we'll hardcode a few image widths to which ...