简体   繁体   English

无服务器:上传的文件必须是非空的 zip。

[英]Serverless: Uploaded file must be a non-empty zip.

I have a python serverless project that I use with AWS.我有一个与 AWS 一起使用的 python 无服务器项目。 But whenever I run sls deploy, i get this error and I noticed in my .serverless that it doesn't actually zip the file, only produces the .json files.但是每当我运行 sls deploy 时,我都会收到此错误,并且我在 .serverless 中注意到它实际上并没有压缩文件,只生成 .json 文件。

An error occurred: ParserLambdaFunction - Uploaded file must be a non-empty zip.发生错误:ParserLambdaFunction - 上传的文件必须是非空的 zip。

my yml looks like this:我的 yml 看起来像这样:

service: my-service

provider:
  name: aws
  runtime: python3.6

package:
  individually: True

plugins:
  - serverless-package-python-functions
  - serverless-python-requirements

custom:
  pkgPyFuncs: # plugin configuration
    buildDir: _build

functions:
  parser:
    handler: handler.parser
    package:
      include:
      artifact: ${self:custom.pkgPyFuncs.buildDir}/my-service-dev-parser.zip
    events:
      - http:
          cors: true
          integration: LAMBDA
          passThrough: WHEN_NO_MATCH
          path: /
          method: post
          request: 
            parameters:
              querystring:
                application/json: "$input.path('$.body')"
                url: true
      - cloudwatchLog: '/aws/lambda/pythonParser'

my package.json looks like this:我的 package.json 看起来像这样:

{
  "name": "my-service",
  "description": "",
  "version": "0.1.0",
  "dependencies": {
    "serverless-package-python-functions": "^0.2.3"
  },
  "devDependencies": {
    "serverless-python-requirements": "^3.0.5"
  }
}

and my folder structure looks like this:我的文件夹结构如下所示:

-my-service
--.serverless
--_pycache_
--_build
--node_modules
--standford-new-2017-06-09
--.gitignore
--handler.py
--package.json
--serverless.yml
--tsconfig.json
--typings.json

On the one hand you can simply remove include or use一方面,您可以简单地删除include或使用

include:
   - ./[put_your_function_code_in_a_folder]
artifact: ....

and as it says - put your code in a subfolder of your dir.正如它所说 - 将您的代码放在您的目录的子文件夹中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM