awslabs / amazon-sqs-python-extended-client-lib

An extension to the Amazon SQS client that enables sending and receiving messages up to 2GB via Amazon S3.
Apache License 2.0
34 stars 4 forks source link

Set S3 subpath #22

Open Pamroni opened 1 month ago

Pamroni commented 1 month ago

I need the ability to set the subpath in my S3 bucket. Right now, it is only accepting the bucket and then the key UUID is used to store the value. There should be a way to add a path variable to save the SQS files into bucket/path/key. In my case, we only have write permission to a certain subpath in the bucket so we need a way to define this.

KatHaruto commented 5 days ago

that can be done like


from sqs_extended_client import SQSExtendedClientSession
from sqs_extended_client.client import S3_KEY_ATTRIBUTE_NAME

client = SQSExtendedClientSession().client("sqs")
client.large_payload_support = "<BUCKET_NAME>"
client.use_legacy_attribute = False
client.always_through_s3 = True

client.send_message(
    QueueUrl="<QUEUE_URL>",
    MessageBody="<DATA>",
    MessageAttributes={
        S3_KEY_ATTRIBUTE_NAME: {"StringValue": "<S3_KEY>", "DataType": "String"},
    },
)