在我的 python 项目中,我有 pre-commit-config.YAML,我想在其中创建我的自定义文件。
如果 python lint 错误大于特定数字,则此文件的目的是使 git commit 失败。以下命令将用于计算行数
pylint api/ | wc -l
Run Code Online (Sandbox Code Playgroud)
有人可以建议一些方法。我是 MAC 和 Python 生态系统的新手?
编辑 sh 文件看起来像这样。
#!/bin/sh
a=$(pylint source/ | wc -l)
b=20
errorsCount="$(echo "${a}" | tr -d '[:space:]')"
if [ $errorsCount -gt $b ]
then
exit 1
fi
Run Code Online (Sandbox Code Playgroud)
我试过
repos:
- repo: local
hooks:
- id: custom-script-file
name: custom-script-file
entry: hooks/pre-commit.sh
language: script
types: [python]
pass_filenames: false
Run Code Online (Sandbox Code Playgroud)
但它不会奏效。
我想使用 Nodejs 将 multipart/form-data 文件上传到 S3。
我尝试过各种方法,但没有一个有效。我能够从 lambda 将内容写入 S3,但是当从 S3 下载文件时,它已损坏。
有人可以为我提供一个可以帮助我的可行示例或步骤吗?
感谢你在期待。
如果您认为如此,请提出另一种选择。
以下是我的 lambda 代码:
export const uploadFile = async event => {
const parser = require("lambda-multipart-parser");
const result = await parser.parse(event);
const { content, filename, contentType } = result.files[0];
const params = {
Bucket: "name-of-the-bucket",
Key: filename,
Body: content,
ContentDisposition: `attachment; filename="${filename}";`,
ContentType: contentType,
ACL: "public-read"
};
const res = await s3.upload(params).promise();
return {
statusCode: 200,
body: JSON.stringify({
docUrl: res.Location
})
};
}
Run Code Online (Sandbox Code Playgroud) amazon-s3 amazon-web-services node.js aws-lambda aws-api-gateway