diff --git a/aws-node-dynamic-binary-via-http-endpoint/block.png b/aws-node-dynamic-binary-via-http-endpoint/block.png new file mode 100644 index 000000000..522fdff97 Binary files /dev/null and b/aws-node-dynamic-binary-via-http-endpoint/block.png differ diff --git a/aws-node-dynamic-binary-via-http-endpoint/block2.jpg b/aws-node-dynamic-binary-via-http-endpoint/block2.jpg new file mode 100644 index 000000000..046d4e4bd Binary files /dev/null and b/aws-node-dynamic-binary-via-http-endpoint/block2.jpg differ diff --git a/aws-node-dynamic-binary-via-http-endpoint/handler.js b/aws-node-dynamic-binary-via-http-endpoint/handler.js new file mode 100644 index 000000000..f4ef64607 --- /dev/null +++ b/aws-node-dynamic-binary-via-http-endpoint/handler.js @@ -0,0 +1,20 @@ +'use strict'; + +const fs = require('fs'); + +module.exports.image = (event, context, callback) => { + const imageContent = fs.readFileSync('./block.png'); + // const response = { + // body: imageContent.toString('base64'), + // isBase64Encoded: true, + // statusCode: 200, + // headers: { + // 'Content-Type': 'image/png', + // }, + // }; + + const response = imageContent.toString('base64'); + + // callback is sending HTML back + callback(null, response); +}; diff --git a/aws-node-dynamic-binary-via-http-endpoint/package.json b/aws-node-dynamic-binary-via-http-endpoint/package.json new file mode 100644 index 000000000..cc8244e4c --- /dev/null +++ b/aws-node-dynamic-binary-via-http-endpoint/package.json @@ -0,0 +1,10 @@ +{ + "name": "serverless-dynamic-binary-via-http-endpoint", + "version": "1.0.0", + "description": "", + "author": "", + "license": "MIT", + "dependencies": { + "pngjs": "^3.0.0" + } +} diff --git a/aws-node-dynamic-binary-via-http-endpoint/serverless.yml b/aws-node-dynamic-binary-via-http-endpoint/serverless.yml new file mode 100644 index 000000000..1a67dda83 --- /dev/null +++ b/aws-node-dynamic-binary-via-http-endpoint/serverless.yml @@ -0,0 +1,19 @@ +service: dynamic-binary-via-http-endpoint +frameworkVersion: ">=1.1.0 <2.0.0" + +provider: + name: aws + runtime: nodejs4.3 + +functions: + image: + handler: handler.image + events: + - http: + method: get + path: image + integration: lambda + request: + passThrough: WHEN_NO_TEMPLATES + template: + image/png: '{}'