RafalWilinski / serverless-puppeteer-layers

Serverless Framework + AWS Lambda Layers + Puppeteer = ❤️
https://dynobase.com
274 stars 36 forks source link

Screenshot don't work #3

Closed 2803media closed 5 years ago

2803media commented 5 years ago

Finally the installation works like a charm:

Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service .zip file to S3 (1.7 MB)...
Serverless: Uploading service .zip file to S3 (45.35 MB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
.................................
Serverless: Stack update finished...
Service Information
service: serverless-puppeteer-layers
stage: dev
region: eu-central-1
stack: serverless-puppeteer-layers-dev
api keys:
  None
endpoints:
  GET - <DEPLOYED_ENDPOINT>
functions:
  puppeteer-orchestrator: serverless-puppeteer-layers-dev-puppeteer-orchestrator
layers:
  chrome: arn:aws:lambda:eu-central-1:0682994076:layer:chrome:5
Serverless: Setting up content handling in AWS API Gateway (takes ~1 min)...

But the screenshot function doesn't work like expected because the image is not displayed, do I miss something?

<DEPLOYED_ENDPOINT>?address=https://google.com

But the base64 image is good, I check with a base64 decoder!

2803media commented 5 years ago

I guess it's related to the encode image and this doesn't work like the gif demo in readme...

2803media commented 5 years ago

If someone got an idea to download the screenshot with curl (not to get the binary but a png or jpg) I'll take the proposition!

With google cloud function i use this code:

const imageBuffer = await page.screenshot({path: '/tmp/gcf_'+parcelle+'_'+i+'.jpg', type: 'jpeg', quality: 95});
res.set('Content-Type', 'image/jpg');
res.send(imageBuffer);
RafalWilinski commented 5 years ago

Can you redeploy and check it once again? This commit: https://github.com/RafalWilinski/serverless-puppeteer-layers/commit/352e16c79a2a1c8f6ba18326eff56478ed0fd07b should fix it.

2803media commented 5 years ago

It works like a charm thanks @RafalWilinski !