Comments (5)
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.
I'm working on this issue...
from serverless-aws-static-file-handler.
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.
Hi, sorry, I just came back to this project and it seems to work great now :)
Chris.
from serverless-aws-static-file-handler.
Thanks for leaving a note @chrisrothwell !
from serverless-aws-static-file-handler.
Related Issues (20)
- Infinite loop of error page loading if error page is missing in custom builds HOT 5
- The error message details does not appear in default and custom error pages HOT 1
- CI link in PR template goes to dead site HOT 3
- due to github secrets restrictions PRs from forks cannot run e2e tests HOT 7
- EMFILE: too many open files when running serverless deploy HOT 4
- Custom filename? HOT 2
- serverless_aws_static_file_handler_1.default is not a constructor HOT 1
- The 404 error page renders literal {errorText} HOT 1
- Support Serverless v3 HOT 5
- local e2e tests failed but the workflow doesn't fail HOT 1
- binaryMediaTypes: */* in example causes issue with API Gateway CORS on OPTIONS request HOT 2
- Depends on 5 megabytes of lodash just for _.get() HOT 2
- chore: pr-auto-merge-dependabot wasn't running due to invalid version reference HOT 1
- e2e_tests check don't work on a PR from a fork due to AWS' configure-aws-credentials bug
- Unicode support HOT 2
- An in-range update of prettier is breaking the build 🚨 HOT 2
- 2.0.2 -> 2.0.3 error message HOT 8
- No Cors headers present. HOT 2
- Update to work with v2 payload? HOT 5
- Unable to get Basic example to work HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serverless-aws-static-file-handler.