Folder won't delete on Amazon S3

后端 未结 5 917
情书的邮戳
情书的邮戳 2021-02-13 14:53

I\'m trying to delete a folder created as a result of a MapReduce job. Other files in the bucket delete just fine, but this folder won\'t delete. When I try to delete it from

5条回答
  •  没有蜡笔的小新
    2021-02-13 15:47

    I was facing the same problem. Tried many login, logout attempts and refresh but problem persist. Searched stackoverflow and found suggestions to cut and paste folder in different folder then delete but didn't worked. Another thing you should look is for versioning that might effect your bucket may be suspending the versioning allow you to delete the folder.

    My solution was to delete it with code. I have used boto package in python for file handling over s3 and the deletion worked when I tried to delete that folder from my python code.

    import boto
    from boto.s3.key import Key
    keyId = "your_aws_access_key"
    sKeyId = "your_aws_secret_key"
    fileKey="dummy/foldertodelete/" #Name of the file to be deleted
    bucketName="mybucket001" #Name of the bucket, where the file resides
    conn = boto.connect_s3(keyId,sKeyId) #Connect to S3
    bucket = conn.get_bucket(bucketName) #Get the bucket object
    k = Key(bucket,fileKey) #Get the key of the given object
    k.delete() #Delete
    

    S3 doesn't keep directory it just have a flat file structure so everything is managed with key. For you its a folder but for S3 it just an key.

    If you want to delete a folder named -> dummy then key would be

    fileKey = "/dummy/"
    

提交回复
热议问题