amazon-sqs-python-extended-client-lib icon indicating copy to clipboard operation
amazon-sqs-python-extended-client-lib copied to clipboard

Set S3 subpath

Open Pamroni opened this issue 1 year ago • 3 comments

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.

Pamroni avatar Oct 31 '24 19:10 Pamroni

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"},
    },
)

KatHaruto avatar Nov 25 '24 09:11 KatHaruto

I am also encountering the problem. The code below does not store the object with the key.

send_message_response = sqs_extended_client.send_message(
    QueueUrl=SQS_QUEUE_URL,
    MessageBody=sqs_message,
    MessageAttributes={
        "S3Key": {
            "StringValue": f"{KEY_NAME}",
            "DataType": "String"
        }
    },
    MessageGroupId=message_group_id,
    MessageDeduplicationId=message_dedupe_id.hexdigest()
)

jecruz avatar Jun 05 '25 02:06 jecruz

@KatHaruto thank you, worked fine for me!

mk-tng avatar Jul 11 '25 14:07 mk-tng