Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

My lambda function is unable to unzip a file

未关闭
#601 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
aws, flask, python
领域
backend, cloud

调研方向

从将 file_content 写入 /tmp/file_path 的 Lambda 函数开始,将通过 Postman 接收的字节与本地输入或 Heroku 输入进行比较。在提取之前,使用所示的 zipfile.ZipFile 调用验证保存的存档;当同一个存档能够在 Lambda 中成功打开并提取时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

I deployed a flask app to lambda that includes a function that unzip a small file (124ko), but nothing works as expected. The unzipping clearly fail and I can't find the reason.

2021-03-23T12:12:46.346+01:00	error [/tmp/39423ff39f7f4378a8f835a20fdcb688.zip]: missing 3183398882 bytes in zipfile

2021-03-23T12:12:46.346+01:00	(attempting to process anyway)

2021-03-23T12:12:46.346+01:00	error [/tmp/39423ff39f7f4378a8f835a20fdcb688.zip]: start of central directory not found;


2021-03-23T12:12:46.346+01:00	zipfile corrupt.

2021-03-23T12:12:46.346+01:00	(please check that you have transferred or created the zipfile in the

2021-03-23T12:12:46.346+01:00	appropriate BINARY mode and that you have compiled UnZip properly)

There is no problem when testing locally and the zip file is okay. So I guess the issue comes from lambda.

The code :

with open(file_path, "wb") as binary_file:
        binary_file.write(file_content)

Expected behavior : The file should unzip without problem just as it does when the app runs locally or in heroku.

P.S. I am using postman for testing

EDIT : also tried to extract with zipfile

with zipfile.ZipFile('/tmp/myfile.zip', 'r') as z:
    z.extractall(fil_dir)

and got the following error :

raise BadZipFile("Bad magic number for central directory")

Originally I was extracting with

os.system("unzip -qq %s -d %s" % (file_path,file_dir))

Any suggestion ?

主要语言
JavaScript
星标
11.5k
派生
4.4k
平均合并
2 小时 55 分钟
30 天内合并 PR
3

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

serverless/examples 的其他 Issue

查看 serverless/examples 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。