Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added aws-node-dynamic-binary-via-http-endpoint/block.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added aws-node-dynamic-binary-via-http-endpoint/block2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions aws-node-dynamic-binary-via-http-endpoint/handler.js
Original file line number Diff line number Diff line change
@@ -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);
};
10 changes: 10 additions & 0 deletions aws-node-dynamic-binary-via-http-endpoint/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "serverless-dynamic-binary-via-http-endpoint",
"version": "1.0.0",
"description": "",
"author": "",
"license": "MIT",
"dependencies": {
"pngjs": "^3.0.0"
}
}
19 changes: 19 additions & 0 deletions aws-node-dynamic-binary-via-http-endpoint/serverless.yml
Original file line number Diff line number Diff line change
@@ -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: '{}'