howto abort all incomplete multipart uploads for a bucket

前端 未结 5 1576
一个人的身影
一个人的身影 2021-02-07 08:36

Sometimes multipart uploads hang or don\'t complete for some reason. In that case you are stuck with orphaned parts that are tricky to remove. You can list them with:

         


        
5条回答
  •  别那么骄傲
    2021-02-07 09:25

    Assuming you have your awscli all setup and it'll output JSON you can use jq to project the needed keys with:

    BUCKETNAME=
    aws s3api list-multipart-uploads --bucket $BUCKETNAME \
    | jq -r '.Uploads[] | "--key \"\(.Key)\" --upload-id \(.UploadId)"' \
    | while read -r line; do
        eval "aws s3api abort-multipart-upload --bucket $BUCKETNAME $line";
    done
    

提交回复
热议问题