GithubHelp home page GithubHelp logo

serverless-apigwy-binary's Introduction

serverless-apigwy-binary

DEPRECATED

Functionality as provided by plugin is available in Serverless Framework natively (since v1.59.0)

contentHandling on http event responses can be confgured simply as:

functions:
  someFunction:
    events:
      - http:
          ....
          response:
            contentHandling: CONVERT_TO_BINARY

Legacy Documentation

Serverless framework plugin to configure Binary responses in API Gateway

Original code from codebox

Installation

Install to your Serverless project via npm

$ npm install --save serverless-apigwy-binary

Usage

Add the plugin to your serverless.yml

# serverless.yml

plugins:
  - serverless-apigwy-binary

Add the property contentHandling: CONVERT_TO_BINARY to an HTTP event

# serverless.yml

functions:
  hello:
    handler: handler.hello
    events:
      - http:
          integration: lambda
          path: hello
          method: get
          contentHandling: CONVERT_TO_BINARY

serverless-apigwy-binary's People

Contributors

activescott avatar medikoo avatar ryanmurakami avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

serverless-apigwy-binary's Issues

Not working with current versions of Serverless (as of v1.35.0) and/or Nodejs (as of v11.0.0)

I'm using serverless v1.35.0 and it is no longer working. You can see this in the output below:

$ serverless deploy
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service .zip file to S3 (133.08 KB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
..........
Serverless: Stack update finished...
Service Information
service: demo-option2-contentHandling
stage: dev
region: us-east-1
stack: demo-option2-contentHandling-dev
api keys:
  None
endpoints:
  GET - https://vcnes1h9b6.execute-api.us-east-1.amazonaws.com/dev/binary/{pathvar+}
functions:
  returnbits: demo-option2-contentHandling-dev-returnbits
layers:
  None
Serverless: Removing old service artifacts from S3...
Serverless: Setting up content handling in AWS API Gateway (takes ~1 min)...
✨  Done in 28.51s.

Note how Serverless: Setting up content handling in AWS API Gateway (takes ~1 min)... is the last line and nothing comes after it confirming that the update was completed. If I inspect the IntegrationResponse via the AWS CLI there is indeed no contentHandling property set.

My exact serverless versions:

├─ @serverless/[email protected]
├─ [email protected]
├─ [email protected]
│  ├─ @serverless/platform-sdk@^0.3.0

My node versions (which come to think of it may be more applicable):

$ node --version
v11.0.0

I have a working fix in my node_modules and will submit a PR with the fix momentarily...

websockets

Doesn't support API Gateway Websockets

Redeploy gateway after adjusting content handling

The gateway needs to be redeployed after it is updated. This may seem obvious for some, but I was stuck on this for a while. I'm not sure if you should update the plugin to redeploy or just make note of this in the readme.

Please add multipart/form-data on docs

I lose several time because images upload from form with multipart/form-data type.
if you coment this on docs can be live saver for other people.

You plugin works perfect

Prevent binary conversion of all api routes

I tried using this plugin to convert one serverless api response to binary, as follows:

get_object:
    handler: Storage/handler.get_object
    events:
      - http:
          path: get_object
          method: get
          cors: true
          contentHandling: CONVERT_TO_BINARY

and

plugins:
  - serverless-apigwy-binary

But now all api route requests are also converted to binary? Is there a workaround for this?

Response setting of function is overwritten

My setting is as following code. In fact, CONVERT_TO_BINARY is successfully setup in apiGateway but response's headers were missing

functionA:
  events:
    - http:
        method: get
        path: ***
        integration: lambda
        contentHandling: CONVERT_TO_BINARY
        response:
          headers:
            Content-Type: "'application/pdf'"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.