[英]Upload file to Amazon S3 with access key and secret, without using SDK
Is there an S3 endpoint which will take the access key, secret, and the file in the body, and then accept the file upload?是否有一个 S3 端点将获取访问密钥、秘密和正文中的文件,然后接受文件上传? I would rather not import the entire AWS SDK for just minimal operations.我宁愿不导入整个 AWS SDK 以进行最少的操作。
My use case: I have an AWS lambda function which uploads files to S3.我的用例:我有一个 AWS lambda function 将文件上传到 S3。 At the moment, I use the AWS SDK for the file upload, but this makes the lambda function package size larger than actually required, since I need to upload aws-sdk npm package along with my code.目前,我使用 AWS SDK 进行文件上传,但这使得 lambda function package 的大小比实际需要的大,因为我需要上传 aws-sdk npm package
Is there an S3 endpoint which will take the access key, secret, and the file in the body, and then accept the file upload?是否有一个 S3 端点将获取访问密钥、秘密和正文中的文件,然后接受文件上传? I would rather not import the entire AWS SDK for just minimal operations.我宁愿不导入整个 AWS SDK 以进行最少的操作。
You never pass the access key and secret directly to the AWS API. You have to sign your requests with the key and secret.您永远不会将访问密钥和秘密直接传递给 AWS API。您必须使用密钥和秘密签署您的请求。 It is much easier to use the SDK than write custom request signing code.使用 SDK 比编写自定义请求签名代码要容易得多。
However, the AWS SDK is included in the AWS Lambda runtime environment .但是,AWS SDK 包含在 AWS Lambda 运行时环境中。 You don't need to upload the SDK as part of your Lambda function deployment unless you need a different version of the SDK than the one provided in the runtime environment.您不需要将 SDK 作为 Lambda function 部署的一部分上传,除非您需要与运行时环境中提供的版本不同的 SDK 版本。
Yes!是的! here is the AWS S3 official RestAPI documentation AWS s3 restAPI docs这是 AWS S3 官方 RestAPI 文档AWS s3 restAPI 文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.