Purge_s3_path

purge_s3_path

The purge_s3_path is a function used to delete all the files inside a specified S3 bucket path. It takes in a single parameter which is the S3 bucket path to be purged.

To use the purge_s3_path function, you need to have proper access permissions to delete files from the specified S3 bucket. Make sure you have the necessary credentials and permissions in place.

Example:

Let’s say you have an S3 bucket named my-bucket with the following structure:

  • my-bucket/
  • my-bucket/folder1/
  • my-bucket/folder1/file1.txt
  • my-bucket/folder1/file2.txt
  • my-bucket/folder2/
  • my-bucket/folder2/subfolder/
  • my-bucket/folder2/subfolder/file3.txt

If you want to delete all the files inside my-bucket/folder1/, you can use the purge_s3_path function as follows:


    purge_s3_path('my-bucket/folder1/');
    

After executing the above code, all the files inside my-bucket/folder1/ will be deleted, resulting in the following structure:

  • my-bucket/
  • my-bucket/folder1/ (empty folder)
  • my-bucket/folder2/
  • my-bucket/folder2/subfolder/
  • my-bucket/folder2/subfolder/file3.txt

It’s important to note that the purge_s3_path function only deletes the files inside the specified path and not the folders themselves. If you want to delete a whole folder along with its subfolders and files, you may need to consider alternative approaches or use additional functions to recursively delete the entire folder structure.

Leave a comment