We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 27dd4fb + 7ab5aa0 commit 8b87fb0Copy full SHA for 8b87fb0
src/lib/templates/imageFunction.js
@@ -4,6 +4,9 @@ const fetch = require('node-fetch')
4
const imageType = require('image-type')
5
const isSvg = require('is-svg')
6
7
+// 6MB is hard max Lambda response size
8
+const MAX_RESPONSE_SIZE = 6291456
9
+
10
function getImageType(buffer) {
11
const type = imageType(buffer)
12
if (type) {
@@ -101,6 +104,13 @@ const handler = async (event) => {
101
104
.resize(width)
102
105
.toBuffer({ resolveWithObject: true })
103
106
107
+ if (imageBuffer.length > MAX_RESPONSE_SIZE) {
108
+ return {
109
+ statusCode: 400,
110
+ body: 'Requested image is too large. Maximum size is 6MB.',
111
+ }
112
113
114
return {
115
statusCode: 200,
116
headers: {
0 commit comments