amazon-web-services - Lambda 中的 AWS create_multipart_upload
问题描述
我正在尝试create_multipart_upload
在 AWS Lambda 中创建 s3,但它不起作用:
“errorMessage”:“2021-08-30T09:14:04.681Z 5f57321e-f82d-4f3e-95ac-13cfcaba4af1 任务在 30.03 秒后超时”
我更改了 Lambda 函数超时,但结果仍然相同。
我的代码:
import logging
import boto3
import time
from botocore.client import Config
from botocore.exceptions import ClientError
def lambda_handler(event, context):
s3_client = boto3.client('s3', config=Config(signature_version='s3v4'), endpoint_url='https://bucket.enpoint_url')
now_day = time.strftime('%Y-%m-%d', time.localtime(time.time()))
bucket_name='bucket_name'
object_name = now_day + '/' + event['path']
try:
response = s3_client.create_multipart_upload(Bucket=bucket_name, Key=object_name)
result = response
except ClientError as e:
logging.error(e)
return None
return result
但是如果我在代码中向 generate_presigned_post 发送请求,我通常会收到响应
为什么generate_presigned_post
有效create_multipart_upload
而不有效?
另外删除端点,create_multipart_upload 也可以。
boto3.client('s3', config=Config(signature_version='s3v4'), endpoint_url='https://bucket.enpoint_url')
-> boto3.client('s3', config=Config(signature_version='s3v4'))
我不知道原因。
解决方案
推荐阅读
- javascript - 如何在ajax函数中获得响应后显示进度条
- javascript - 自定义 JS 变量来计算购物车中的商品数量
- java - DispatcherServlet 无法转换为类 jakarta.servlet.Servlet (ClassCastException)
- flutter - 将 Alertbox 创建为单独的小部件 Flutter
- python - 基于特定值范围的numpy ndarray条件索引
- c# - 在 c# .net core 中创建自定义文件扩展名
- tmlanguage - 有没有办法防止(除了).tmLanguage 中“匹配”中的特定字符
- html - 将文本添加到边框而不添加间距
- php - 接收推送通知两次 firebase PHP 脚本
- jsp - 将 Web 应用程序与 IdentityServer 集成