[Python] how to setting limit size of file when creating AWS S3 presigned url via boto3

Discussão em 'Python' iniciado por Stack, Julho 18, 2025.

  1. Stack

    Stack Membro Participativo

    i want to create S3 presigned url and given to the client with spesific limit file size, in example min file size in 200kib and max file size is 1024 kib

    I create using function 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],
    },
    )


    and i found error, because parameter is invalid for content length range.

    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


    where i can put the content length range in this functions ? Thanks in advance

    Continue reading...

Compartilhe esta Página