Git Product home page Git Product logo

Comments (5)

activescott avatar activescott commented on June 14, 2024

Thanks for letting me know @chrisrothwell ! 👍

Looks like a bug. The binary support via API Gateway used to be non-trivial, but it looks like it has improved. I think the key part of the bug is at https://github.com/activescott/serverless-aws-static-file-handler/blob/master/StaticFileHandler.js#L141 - Note how if it is text it adds response headers, but if binary just returns the whole blob (without setting any headers).

As I mentioned, the binary support via API Gateway used to be wonky but it looks like they have improved it:

If body is a binary blob, you can encode it as a Base64-encoded string and set isBase64Encoded to true. Otherwise, you can set it to false or leave it unspecified.

So I think now, we could just have the binary code path return something more like the following instead:

let response = {
          statusCode: statusCode,
          headers: {
            'Content-Type': mimeType
          },
          isBase64Encoded: true,
          body: Buffer.from(stream).toString('base64')
}

Would you be up for submitting a pull request for this with an example and tests? If not, if you could create a very simple example repo demonstrating problem in a public github repo and reply here with a link, I'll use that to fix the issue, confirm it works with your test repo, and write some tests to make sure it stays stable.

from serverless-aws-static-file-handler.

activescott avatar activescott commented on June 14, 2024

I'm working on this issue...

from serverless-aws-static-file-handler.

activescott avatar activescott commented on June 14, 2024

This should now let you do what you want if you using Lambda Proxy Integration with the new 2.0.0-beta1 release. Get it from npm. Please feel free to re-open the issue if you have questions, concerns, or suggestions.

from serverless-aws-static-file-handler.

chrisrothwell avatar chrisrothwell commented on June 14, 2024

Hi, sorry, I just came back to this project and it seems to work great now :)

Chris.

from serverless-aws-static-file-handler.

activescott avatar activescott commented on June 14, 2024

Thanks for leaving a note @chrisrothwell !

from serverless-aws-static-file-handler.

Related Issues (20)

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.