Maintain empty dir structure in AWS S3 after deleting last file

When using the AWS SDK for Java library (used by cognitect-labs/aws-api), I am experiencing an issue with DeleteObject (AWS Documentation).

If I delete the last object in a directory, I expect to be left with an empty directory. However, DeleteObject deletes the directory as well.

(require '[ :as aws])

;; Copying works fine
(aws/invoke aws/client
            {:op :CopyObject
             :request {:Bucket "bucket"
                       :CopySource "bucket/dirA/f1"
                       :Key "dirB/f1"}})

;; However, deleting removes f1 and dirA (if dirA is empty)
(aws/invoke aws/client
            {:op :DeleteObject
             :request {:Bucket "bucket"
                       :Key "dirA/f1"}})

Is there a way to avoid this behavior?

No, there is no way to avoid this behavior. This is the expected behavior of the AWS S3 API. When you delete the last object in a directory, the directory itself is also deleted. If you want to keep the directory, you will need to create a new empty object with the same name as the directory.