Skip to content
This repository has been archived by the owner on Jun 29, 2020. It is now read-only.

Documentation

Stephanie Kwak edited this page Oct 12, 2016 · 8 revisions

Superglue API (or whatever it is named)

Superglue allows you to quickly setup your own API -- using AWS Lambda, API Gateway, and S3 -- to merge PDFs with AWS's serverless infrastructure. This gives you the ability to merge PDFs when you want them, for a variety of apps, without having to manage your own server.

This project uses PDFtk built from CentOS from this repo: https://github.com/lob/lambda-pdftk-example

##Setup## Make sure you have an AWS Account and a AWS credentials file before you begin. You will also need to setup an 1.) S3 Bucket (with configurations set to keep merged PDF file private or public, storage length of merged PDF, etc), 2) an API Gateway endpoint (configured to be able to trigger the Lambda function), and 3) a Lambda function (which will be allowed to access the S3 bucket).

Note: Will point to documentation about the steps to setup AWS. Won't get as lengthy as some documentation gets on this, but won't be so brief so as to be unhelpful to those new to AWS. Will list out steps of what needs to happen for setup.

Will the Serverless framework to see if it might simplify the above: https://serverless.com/blog/releasing-serverless-framework-v1-and-fundraising/.

##Memory and Execution Time https://s3.amazonaws.com/lambda-tools/pricing-calculator.html

##URL https://example.amazonaws.com/superglue Note: How to advise someone to set up the URL on API Gateway? Could either do it through the AWS Console (how I did it) or through the CLI. Part of that entire config dilemma mentioned above

##Method: POST

##Data Params

The body payload should include a pdfUrls parameter, which takes an array of URL strings of the PDFs for merging.

{
  "pdfUrls":
    [string, string, string]
}
``` 

Example usage: 

```
{
  "pdfUrls":
    [
      "https://s3.amazonaws.com/superglue/PCAH_PDF_TEMPLATE.pdf",
      "https://s3.amazonaws.com/superglue/hello.pdf"
    ]
}
```
##Success Response 
If successful, you will get the following response:

`Code: 200` 
`Content`: 

```
{
  "mergedPDF": "https://s3.amazonaws.com/superglue/merged/1ed989e5-026d-41f6-917f-953b4fd35bd8.pdf"
}
```
(example)

Error Response
https://docs.aws.amazon.com/apigateway/api-reference/handling-errors/

Sample Call
You can use the example file in the `/pdf` directory of the repo, `hello.pdf`, to test the endpoint. 
 
Documentation inspired by:
- https://gist.github.com/iros/3426278
- https://github.com/Miserlou/Zappa
- https://github.com/awslabs/lambda-apigateway-twilio-tutorial
- http://www.ryanray.me/serverless-slack-integrations
Clone this wiki locally