Skip to main content
richardk74259717
Participant
November 3, 2023
Answered

ColdFusion 2023 and Amazon S3 listAll(parameterStruct)

  • November 3, 2023
  • 1 reply
  • 381 views

I upgraded to ColdFusion 2023, and now my Amazon S3 functionality is broken.  Looking at the ColdFusion documentation, I should be able to use the listAll(parameterStruct) function to get my desired results, but for some reason, I am getting errors.   I am trying to retrieve a list of objects inside a bucket.   The documentation only shows how to get a list of buckets in a storage account. But it says that I should be able to retrieve a list of objects inside a bucket, but doesn't provide an example.  Would anyone have a complete example of how to do this? 

    This topic has been closed for replies.
    Correct answer richardk74259717

    I figured it out too. Except I used "root" instead of "bucket" below.

    bucketListContents = s3Obj.root("BUCKET_NAME",false).listAll(prefix);

     

    Thank you for your help

    1 reply

    Participating Frequently
    November 4, 2023

    I'm having the same problem. I normally just use the aws s3 cli for a lot of my work but I wasnted to automate some of that within CF.  To get contents of  bucket_name, I should just pass that in the struct right?

    sqs = getCloudService(s3Cred, "s3" )

                listBucket = {
                    "bucket" : "bucket_name"
                }

                bucketList=sqs.listAll(listBucket);

    Unable to invoke method '' on object ''.
    Participating Frequently
    November 4, 2023

    Figured it out.

     

    s3Obj = getCloudService(s3Cred, "s3" )

    prefix ={
        "prefix"="PATH/TO/FILE/YOU/WANT/"
    };

    bucketListContents = s3Obj.bucket("BUCKET_NAME",false).listAll(prefix);

    writeDump(var='#bucketListContents#', abort='false');
    richardk74259717
    richardk74259717AuthorCorrect answer
    Participant
    November 6, 2023

    I figured it out too. Except I used "root" instead of "bucket" below.

    bucketListContents = s3Obj.root("BUCKET_NAME",false).listAll(prefix);

     

    Thank you for your help