idea-html2pdf
Advanced tools
Comparing version 2.2.10 to 2.2.11
@@ -38,3 +38,3 @@ import * as Handlebars from 'handlebars'; | ||
* TO USE ONLY when the expected PDF payload is very large (it's slower than the altenative). | ||
* It takes advantage of an intermediate S3 bucket to avoid Lambda's payload limits. | ||
* It takes advantage of an intermediate S3 bucket to avoid Lambda's payload limits (in & out). | ||
* @param params the parameters to create the PDF | ||
@@ -45,2 +45,6 @@ * @return the PDF data (Buffer) | ||
/** | ||
* Prepare a helper S3 file which contains the parameters to send to the Lambda Function, to avoid payload limits. | ||
*/ | ||
private getS3ParamsFileURL; | ||
/** | ||
* Create the signedURL to a new PDF created by an HTML source. | ||
@@ -47,0 +51,0 @@ * @param params the parameters to create the PDF |
@@ -139,3 +139,3 @@ "use strict"; | ||
* TO USE ONLY when the expected PDF payload is very large (it's slower than the altenative). | ||
* It takes advantage of an intermediate S3 bucket to avoid Lambda's payload limits. | ||
* It takes advantage of an intermediate S3 bucket to avoid Lambda's payload limits (in & out). | ||
* @param params the parameters to create the PDF | ||
@@ -146,6 +146,7 @@ * @return the PDF data (Buffer) | ||
try { | ||
const paramsFromURL = await this.getS3ParamsFileURL(params); | ||
const invokeCommand = new client_lambda_1.InvokeCommand({ | ||
FunctionName: this.options.lambdaFnViaS3BucketName, | ||
InvocationType: 'RequestResponse', | ||
Payload: JSON.stringify(params) | ||
Payload: JSON.stringify({ paramsFromURL }) | ||
}); | ||
@@ -164,2 +165,15 @@ const { Payload } = await lambda.send(invokeCommand); | ||
/** | ||
* Prepare a helper S3 file which contains the parameters to send to the Lambda Function, to avoid payload limits. | ||
*/ | ||
async getS3ParamsFileURL(params) { | ||
const Bucket = params.s3Bucket; | ||
const Key = `${params.s3Prefix}/${Date.now()}${Math.random().toString(36).slice(2)}.json`; | ||
const ContentType = 'application/json'; | ||
const Body = JSON.stringify(params); | ||
const putCommand = new client_s3_1.PutObjectCommand({ Bucket, Key, ContentType, Body, IfNoneMatch: '*' }); | ||
await s3.send(putCommand); | ||
const getCommand = new client_s3_1.GetObjectCommand({ Bucket, Key }); | ||
return await (0, s3_request_presigner_1.getSignedUrl)(s3, getCommand, { expiresIn: 120 }); | ||
} | ||
/** | ||
* Create the signedURL to a new PDF created by an HTML source. | ||
@@ -172,3 +186,3 @@ * @param params the parameters to create the PDF | ||
const Bucket = params.s3Bucket; | ||
const Key = params.s3Prefix.concat('/', Date.now().toString().concat(Math.random().toString(36).slice(2)), '.pdf'); | ||
const Key = `${params.s3Prefix}/${Date.now()}${Math.random().toString(36).slice(2)}.pdf`; | ||
const upload = new lib_storage_1.Upload({ | ||
@@ -175,0 +189,0 @@ client: s3, |
{ | ||
"name": "idea-html2pdf", | ||
"version": "2.2.10", | ||
"version": "2.2.11", | ||
"description": "IDEA helper for generating a PDF from HTML contents", | ||
@@ -38,6 +38,6 @@ "license": "MPL-2.0", | ||
"peerDependencies": { | ||
"@aws-sdk/client-lambda": "^3.616.0", | ||
"@aws-sdk/client-s3": "^3.614.0", | ||
"@aws-sdk/lib-storage": "^3.616.0", | ||
"@aws-sdk/s3-request-presigner": "^3.616.0" | ||
"@aws-sdk/client-lambda": "^3.670.0", | ||
"@aws-sdk/client-s3": "^3.673.0", | ||
"@aws-sdk/lib-storage": "^3.673.0", | ||
"@aws-sdk/s3-request-presigner": "^3.673.0" | ||
}, | ||
@@ -44,0 +44,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56994
603