AWS_Lambda_in_Action icon indicating copy to clipboard operation
AWS_Lambda_in_Action copied to clipboard

Chapter4 - Code doesn't work

Open clopez-logica opened this issue 3 years ago • 0 comments

Program fails when calling gm(response.Body);

` function transformImage(response, next) { console.log('response object: ', util.inspect(response, {depth: 5}));

		gm(response.Body).size(function(err, size) {
			
			if (err) {
				console.error('Error transforming image: ', util.inspect(err));
				return;					
			}
			
			const metadata = response.Metadata;
			console.log('Metadata:\n', util.inspect(metadata, {depth: 5}));
			
			let maxWidth = DEFAULT_MAX_WIDTH;
			if ('width' in metadata) {
				maxWidth = metadata.width;
			}

// rest of the code } `

LOGS

`INFO response object: { AcceptRanges: 'bytes', LastModified: 2020-09-13T23:24:54.000Z, ContentLength: 118518, ETag: '"f9883cd7f57c3772e01fa7a06db160b7"', ContentType: 'image/jpeg', Metadata: {}, Body: <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 01 00 48 00 48 00 00 ff db 00 43 00 03 02 02 03 02 02 03 03 03 03 04 03 03 04 05 08 05 05 04 04 05 0a 07 07 06 ... 118468 more bytes> }

ERROR Error transforming image: Error: write EPIPE at afterWriteDispatched (internal/stream_base_commons.js:154:25) at writeGeneric (internal/stream_base_commons.js:145:3) at Socket._writeGeneric (net.js:786:11) at Socket._write (net.js:798:8) at doWrite (_stream_writable.js:403:12) at writeOrBuffer (_stream_writable.js:387:5) at Socket.Writable.write (_stream_writable.js:318:11) at gm._spawn (/var/task/node_modules/gm/lib/command.js:253:18) at gm._exec (/var/task/node_modules/gm/lib/command.js:190:17) at gm.proto. [as size] (/var/task/node_modules/gm/lib/getters.js:68:12) { errno: 'EPIPE', code: 'EPIPE', syscall: 'write' }

`

clopez-logica avatar Sep 13 '20 23:09 clopez-logica