Comments (6)
Thanks, it's looks working now!
from aws-sam-cli.
Hi @dyingsunlight, thanks for reporting the issue. I tried to deploy the app and browse the URL but could not see the image. As for the isBase64Encoded: False
in the debug logs, it seems this is for the input event sent to the lambda function. I think what you are looking for is the response to return True for isBase64Encoded
and looking at this code, the boolean value is a string. Can you check if setting it to a string works?
from aws-sam-cli.
It's not working... I tried setting isBase64Encoded
to 'true'
and 'True'
, but the debug message still outputs: 'isBase64Encoded': False
.
The debug logs:
Constructed Event 1.0 to invoke Lambda. Event: {'version': '1.0', 'httpMethod': 'GET', 'body': None, 'resource': '/hello-world', 'requestContext': {'resourceId': '123456', 'apiId': '1234567890',
'resourcePath': '/hello-world', 'httpMethod': 'GET', 'requestId': '35b543fb-3f9b-4ba4-80a0-c1983c882814', 'accountId': '123456789012', 'stage': 'Prod', 'identity': {'apiKey': None, 'userArn': None, 'cognitoAuthenticationType':
None, 'caller': None, 'userAgent': 'Custom User Agent String', 'user': None, 'cognitoIdentityPoolId': None, 'cognitoAuthenticationProvider': None, 'sourceIp': '127.0.0.1', 'accountId': None}, 'extendedRequestId': None, 'path':
'/hello-world', 'protocol': 'HTTP/1.1', 'domainName': '127.0.0.1:8090', 'requestTimeEpoch': 1702792298, 'requestTime': '17/Dec/2023:05:51:38 +0000'}, 'queryStringParameters': None, 'multiValueQueryStringParameters': None,
'headers': {'Host': '127.0.0.1:8090', 'Connection': 'keep-alive', 'Cache-Control': 'max-age=0', 'Sec-Ch-Ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"', 'Sec-Ch-Ua-Mobile': '?0', 'Sec-Ch-Ua-Platform':
'"Windows"', 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36', 'Accept':
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7', 'Sec-Fetch-Site': 'none', 'Sec-Fetch-Mode': 'navigate', 'Sec-Fetch-User': '?1',
'Sec-Fetch-Dest': 'document', 'Accept-Encoding': 'gzip, deflate, br', 'Accept-Language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en;q=0.7,ja;q=0.6,ru;q=0.5', 'X-Forwarded-Proto': 'http', 'X-Forwarded-Port': '8090'}, 'multiValueHeaders':
{'Host': ['127.0.0.1:8090'], 'Connection': ['keep-alive'], 'Cache-Control': ['max-age=0'], 'Sec-Ch-Ua': ['"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"'], 'Sec-Ch-Ua-Mobile': ['?0'], 'Sec-Ch-Ua-Platform':
['"Windows"'], 'Upgrade-Insecure-Requests': ['1'], 'User-Agent': ['Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'], 'Accept':
['text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7'], 'Sec-Fetch-Site': ['none'], 'Sec-Fetch-Mode': ['navigate'], 'Sec-Fetch-User': ['?1'],
'Sec-Fetch-Dest': ['document'], 'Accept-Encoding': ['gzip, deflate, br'], 'Accept-Language': ['zh-CN,zh;q=0.9,zh-TW;q=0.8,en;q=0.7,ja;q=0.6,ru;q=0.5'], 'X-Forwarded-Proto': ['http'], 'X-Forwarded-Port': ['8090']},
'pathParameters': None, 'stageVariables': None, 'path': '/hello-world', 'isBase64Encoded': False}
I believe the issue is that, according to the documentation, the 'isBase64Encoded'
value should be a boolean type, not a string type.
from aws-sam-cli.
Marking this as a bug for the team to investigate the right behavior here.
from aws-sam-cli.
Hi, It looks like because in the template provided the api definition does not have anything declared for the BinaryMediaTypes property SAM CLI does not try to decode the image. Changing the template to the following fixed the issue for me
{
"AWSTemplateFormatVersion": "2010-09-09",
"Transform": "AWS::Serverless-2016-10-31",
"Description": "",
"Resources": {
"HelloWorld": {
"Type": "AWS::Serverless::Function",
"Properties": {
"CodeUri": "./lambda",
"Handler": "hello-word.handler",
"Runtime": "nodejs18.x",
"Events": {
"HelloWorldEvent0": {
"Type": "Api",
"Properties": {
"Path": "/hello-world",
"Method": "get",
"RestApiId": {
"Ref": "HelloWorldApi"
}
}
}
},
"Timeout": 60,
"MemorySize": 1024
}
},
"HelloWorldApi": {
"Type": "AWS::Serverless::Api",
"Properties": {
"StageName": "prod",
"BinaryMediaTypes": ["image/png"]
}
}
}
}
Alternatively changing the event type to HttpApi
will also cause the image to be decoded. It looks like the behaviour for decoding base64 images is defined here
from aws-sam-cli.
⚠️ COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
from aws-sam-cli.
Related Issues (20)
- Bug: [WinError 3] The system cannot find the path specified HOT 4
- Feature request: Deploy Lambdas with concurrency HOT 3
- Bug: sam sync with python causes endless cpu saturation HOT 11
- Bug: sam build - EmptyKeyError HOT 1
- Bug: Unable to run sam local invoke on Apple Silicon HOT 14
- Cannot sam local start-api without specifying an image HOT 1
- Bug: sam local start-api - ReadTimeout HOT 3
- Bug: "Timed out while attempting to establish a connection to the container" error after fresh install of Docker and AWS SAM HOT 5
- Bug: sam build - JSONDecodeError HOT 1
- Bug: No new Lambda Versions are deployed with Lambda configurations changes HOT 2
- Bug: Change Parameter's Default value doesn't reflect HOT 4
- Bug: AWS ADOT LAMBDA layer stuck when using local invoke HOT 5
- Bug: AWS::Serverless::Function `ImageUri` with map (ex: using `!Sub`) fails with type error HOT 7
- Access to internal enterprise host (Github entreprise) HOT 1
- Bug: sam deploy - ConnectionError HOT 2
- Bug: Invoke failed error=ErrAgentNameCollision HOT 4
- Bug: SAM Doesn't recognize changes related to intrinsic functions (#6610) HOT 1
- Bug: Error: The runtime 'provided.al2023' is unsupported. (golang) HOT 6
- `BuildMethod: esbuild` does not include bundled files HOT 2
- Bug: AWS::Events::Rule EventBusName -> 'name' member must satisfy regular expression pattern [\.\-_A-Za-z0-9]+ 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 aws-sam-cli.