Lambda error: Could not unzip uploaded file
See original GitHub issueI’m trying to update lambda function code
import base64
import boto3
import glob
import os
import zipfile
from StringIO import StringIO
buf = StringIO()
with zipfile.ZipFile(buf, 'w') as z:
for f in glob.glob(os.path.join(os.path.dirname(__file__), 'app/*.py')):
z.write(os.path.abspath(f), os.path.basename(f))
buf.seek(0)
pkg = base64.b64encode(buf.read())
client = boto3.client('lambda')
res = client.update_function_code(
FunctionName='my_function',
ZipFile=pkg,
Publish=False
)
Get the ClientError
botocore.exceptions.ClientError: An error occurred (InvalidParameterValueException) when calling the UpdateFunctionCode operation: Could not unzip uploaded file. Please check your file, then try to upload again.
I tried to upload the same package with awscli
and it works fine
aws lambda update-function-code --function-name my_function --zip-file=fileb://app.zip
My environment
Python 2.7.9
boto3==1.2.3
botocore==1.3.25
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Could not unzip uploaded file. Please check your file ... - GitHub
I was stuck with this error CREATE_FAILED | AWS::Lambda::LayerVersion | PrismaLayer958161C6 | Could not unzip uploaded file. Please check your file, ...
Read more >Troubleshoot Lambda deployment package upload errors - AWS
When I try to upload my AWS Lambda deployment package, I get either a permission denied or unable to import module error. How...
Read more >Node.js – AWS Lambda Error: Could not unzip uploaded file
I am trying to update the code in my lambda function using the aws-sdk package for node.js. So I wrote the following script...
Read more >Could not unzip uploaded file. Please check your file, then try ...
AWS lambda function through terraform - Could not unzip uploaded file. Please check your file, then try to upload again.
Read more >Could Not Unzip Uploaded File On Creation Of Lambda ...
AWS Lambda Error: Could not unzip uploaded file. Solution: ZipFile needs to be a Buffer. That means you have to read the file...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
in case this is useful for anyone, this works.
I resolved the issue by following this guide. My final code was: