python - 通过 boto3 创建 AWS S3 预签名 url 时如何设置文件的限制大小
问题描述
我想创建 S3 预签名 url 并以特定限制文件大小提供给客户端,例如最小文件大小为 200kib,最大文件大小为 1024 kib
我使用函数创建create_presigned_url
create_presigned_url = await s3_client.create_presigned_url(
client_method="put_object",
method_parameters={
"Bucket": settings.S3_Bucket,
"Key": f"application/registration/{find_application_id.get('application_id')}/{req_upload_document.document_type}/{first_char}{time_reformat}.jpg",
"ContentLengthRange": [200, 1024],
},
)
我发现错误,因为参数对于内容长度范围无效。
botocore.exceptions.ParamValidationError: Parameter validation failed:
Unknown parameter in input: "ContentLengthRange", must be one of: ACL, Body, Bucket, CacheControl, ContentDisposition, ContentEncoding, ContentLanguage, ContentLength, ContentMD5, ContentType, Expires, GrantFullControl, GrantRead, GrantReadACP, GrantWriteACP, Key, Metadata, ServerSideEncryption, StorageClass, WebsiteRedirectLocation, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, SSEKMSKeyId, SSEKMSEncryptionContext, BucketKeyEnabled, RequestPayer, Tagging, ObjectLockMode, ObjectLockRetainUntilDate, ObjectLockLegalHoldStatus, ExpectedBucketOwner
我可以在哪里把内容长度范围放在这个函数中?提前致谢
解决方案
推荐阅读
- javascript - 在 JS 循环中验证多个 html 表格行输入的最有效方法?
- amcharts - 我的步骤 amcharts 因数据点过多而消失
- javascript - 如何在 lerna exec 命令中执行 npm 运行测试?
- database - 数据透视表是否可以与另一个表建立多对多关系?
- asp.net-core - 如何让 Blazor WebAssembly 应用程序监听 http 请求?
- python - 在 Dask 中,如何根据全局(非工作人员)资源约束限制任务的调度?
- laravel - 描述标签上富文本字段的刀片视图
- python - 无法使用正则表达式将命名组拆分为日期格式的列
- javascript - 查询参数键中的方括号
- delphi - 如何设置 TClientDataSet 字段名称和 displayName