Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

My lambda function is unable to unzip a file

Đang mở
#601 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
aws, flask, python
Lĩnh vực
backend, cloud

Hướng nghiên cứu

Bắt đầu với hàm Lambda ghi file_content vào /tmp/file_path và so sánh các byte nhận được qua Postman với đầu vào cục bộ hoặc đầu vào trên Heroku. Xác minh archive đã lưu bằng lệnh gọi zipfile.ZipFile được hiển thị trước khi giải nén; hoàn thành khi cùng archive đó mở và giải nén thành công trong Lambda.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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 ?

Ngôn ngữ chính
JavaScript
Star
11.5k
Fork
4.4k
Merge trung bình
2 giờ 55 phút
Pull request đã merge (30 ngày)
3

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của serverless/examples

Tất cả issue của serverless/examples

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.