我工作的数据管理应用程序,其中客户端可以上传zip file(approx 250 MB)多text files(approx 1500 MB)上AWS S3。
但是由于有限的内存aws lamda(最大1536MB大小),我能够提取(50 MB)的zip文件和(500 MB)的提取文件。
由于我需要在提取时对提取的文件添加一些验证,之后我必须将文件的所有内容存储到数据库中。
目前,我正在存储文件的内容,aws-lambda tmp location其中也可以使用最大500MB的限制。
任何可以帮助我完成上述任务并进行验证的流媒体概念都将对我有所帮助。
我可以一起去,EC2, ECS但现在我只想一起去AWS-Lambda。
通过此代码,我将zip文件提取并上传到另一个S3存储桶。
任何其他类似流媒体的概念对我都会有所帮助,因为我对流媒体概念不是很熟悉,我在这里提出一些想法来解决我的问题。
s3.getObject(params, (err, data) => {
if (err) {
console.log('Error', err);
var message = `Error getting object ${key} from bucket ${bucket}. Make sure they exist and your bucket is in the same region as this function.`;
console.log(message);
// callback(message);
} else {
console.log('Started to …Run Code Online (Sandbox Code Playgroud) 我已经使用POSTLambda Proxy方法设置了一个APIGateway资源,并OPTIONS为CORS头设置了一个方法.
该OPTIONS方法返回以下标头:
$ curl -i -X OPTIONS https://xxxxxxxxx.execute-api.eu-central-1.amazonaws.com/dev/endpoint1
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 0
Connection: keep-alive
Date: Sat, 18 Feb 2017 17:07:17 GMT
x-amzn-RequestId: xxxx
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token
Access-Control-Allow-Methods: POST,OPTIONS
X-Cache: Miss from cloudfront
Via: 1.1 xxxx.cloudfront.net (CloudFront)
X-Amz-Cf-Id: xxxx==
Run Code Online (Sandbox Code Playgroud)
然而,当我POST使用生成的Javascript SDK 调用端点时,Chrome浏览器控制台会显示以下错误:
XMLHttpRequest cannot load https://xxxx.execute-api.eu-central-1.amazonaws.com/dev/endpoint1.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:8080' is therefore not allowed access.
Run Code Online (Sandbox Code Playgroud)
以及Firefox:
Cross-Origin Request Blocked:
The Same …Run Code Online (Sandbox Code Playgroud) zappa可以很容易地用于运行烧瓶应用程序.但它每个应用程序只创建一个lambda函数.我可以为每个声明的python函数使用单独的lambda函数吗?
LocalStack很整洁,但很难找到它的文档.我无法访问连接到Lambda函数的API网关代理端点.
我能想到的唯一事情是当我为网关进行put-integration时,我不知道如何处理凭证参数(假设这是100%本地...我没有使用真正的AWS账户)所以我现在留下评论:
aws --endpoint-url=http://localhost:4567 apigateway \
put-integration \
--region us-west-2 \
--rest-api-id 0091232159 \
--resource-id 3732709762 \
--http-method ANY \
--type AWS_PROXY \
--integration-http-method POST \
--uri arn:aws:lambda:us-west-2:000000000000:function:PostProposal \
#--credentials arn:aws:iam::123456789012:role/apigAwsProxyRole
Run Code Online (Sandbox Code Playgroud)
我的同事发现了一个线程,听起来好像是LocalStack中的一个错误:
https://github.com/atlassian/localstack/issues/129
无论如何,这是我的API在我做的时候的样子aws --endpoint-url=http://localhost:4567 apigateway get-resources --rest-api-id 0091232159:
{
"items": [
{
"id": "3312801A-ZA-Z6",
"path": "/",
"resourceMethods": {
"GET": {}
}
},
{
"id": "3732709762",
"parentId": "3312801A-ZA-Z6",
"pathPart": "{proxy+}",
"path": "/{proxy+}",
"resourceMethods": {
"GET": {},
"ANY": {
"httpMethod": "ANY",
"authorizationType": "NONE",
"methodIntegration": {
"type": "AWS_PROXY",
"httpMethod": "ANY", …Run Code Online (Sandbox Code Playgroud) 我在AWS Compute Blog中找到了以下代码示例:
package main
import (
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
func handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
return events.APIGatewayProxyResponse{
StatusCode: 200,
Body: "Hello World",
}, nil
}
func main() {
lambda.Start(handler)
}
Run Code Online (Sandbox Code Playgroud)
由于lambda.Start只接受一个处理程序而Go程序的入口点是主函数,这是否意味着一个CodeStar项目只能由一个处理程序组成?
我理解lambda函数的大小应该很小,最好处理一个功能,但似乎需要创建很多项目并且很难管理.我理解正确吗?
对于node.js 使用清晰图像调整大小库https://github.com/lovell/sharp时,图像正在旋转.
我没有代码说.rotate(),为什么它被旋转,我怎么能阻止它旋转?
我使用的是由AWS提供的无服务器,图像缩放例如: https://github.com/awslabs/serverless-image-resizing使用拉姆达在飞行中调整图像如果缩略图不存在
S3.getObject({Bucket: BUCKET, Key: originalKey}).promise()
.then(data => Sharp(data.Body)
.resize(width, height)
.toFormat('png')
.toBuffer()
)
.then(buffer => S3.putObject({
Body: buffer,
Bucket: BUCKET,
ContentType: 'image/png',
Key: key,
}).promise()
)
.then(() => callback(null, {
statusCode: '301',
headers: {'location': `${URL}/${key}`},
body: '',
})
)
.catch(err => callback(err))
Run Code Online (Sandbox Code Playgroud)
原始大图:
已调整大小的图片:请注意它已被旋转:
我是Amazon服务的新手。我已经在其他应用程序中将FIREBASE和PUBNUB用于浏览器通知。我想使用AWS SNS构建浏览器通知,例如FIREBASE或PUBNUB。
对于Web应用程序前端,我正在使用ReactJs和后端Nodejs lambda函数。
是否可以将SNS用于浏览器或Web应用程序通知?请指教。
谢谢
C#中的AWS Lambda函数处理程序是否提供取消令牌?
我已经阅读了AWS网站上的文档(https://docs.aws.amazon.com/lambda/latest/dg/dotnet-programming-model-handler-types.html),但在任何提及取消的地方都看不到令牌。我还检查了ILambdaContext传递给执行方法的,但是那里什么也没有。
我以前使用过Azure Functions,它们只是将它作为本文所述的函数的另一个参数传递给了我:https : //docs.microsoft.com/zh-cn/azure/azure-functions/functions-dotnet-类别库#取消令牌
我有一个 AWS Lambda 函数,在成功将其设置为授权方后,我试图为其提供权限。
基本上我想在 CloudFromation 中实现以下目标 -
以下是我的 CloudFormation 资源,无法设置权限 -
GWAuthPermission:
Type: "AWS::Lambda::Permission"
Properties:
Action: lambda:InvokeFunction
FunctionName: !GetAtt AuthTest.Arn
Principal: "apigateway.amazonaws.com"
SourceArn: !Sub "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ApiGatewayRestApi}/authorizers/${AuthTest}"
Run Code Online (Sandbox Code Playgroud)
ApiGatewayRestApi - 是网关
AuthTest的逻辑 Id - 是自定义 Auth lambda 函数的逻辑 Id
amazon-web-services aws-cloudformation aws-lambda aws-api-gateway
aws-lambda ×10
node.js ×3
amazon-s3 ×2
amazon-sns ×1
c# ×1
go ×1
javascript ×1
python-3.x ×1
reactjs ×1
sharp ×1