I have a directory in my s3 bucket 'test', I want to delete this directory. This is what I do
s3 = boto3.resource('s3') s3.Object(S3Bucket,'test').delete()
and get an answer like this
{'ResponseMetadata': {'HTTPStatusCode': 204, 'HostId': '************', 'RequestId': '**********}}}
but my directory is not deleted!
I tried with all combinations of "/ test", "test /" and "/ test /", etc., also with the file inside this directory and with an empty directory, and all failed to delete the "test".
delete_objects HTTP-. 1000 .
delete_objects
https://boto3.readthedocs.io/en/latest/reference/services/s3.html#S3.Bucket.delete_objects
import boto3 s3 = boto3.resource('s3') bucket = s3.Bucket('my-bucket') objects_to_delete = [] for obj in bucket.objects.filter(Prefix='test/'): objects_to_delete.append({'Key': obj.key}) bucket.delete_objects( Delete={ 'Objects': objects_to_delete } )
. . .
S3 , . /, prefix/my-key.txt, AWS , .
/
prefix/my-key.txt
"", , . , boto3 , . , - :
s3 = boto3.resource('s3') bucket = s3.Bucket('my-bucket-name') for obj in bucket.objects.filter(Prefix='test/'): s3.Object(bucket.name, obj.key).delete()
Source: https://habr.com/ru/post/1611442/More articles:EclipseLink: Missing class for type indicator field value - javaFailed to solve: com.firebase: firebase-client-android: 2.3.1 - androidКак скрыть будущие или прошлые даты в UIDatePickerView - iosJava 8 with Jetty issue for Linux - javaDoes Jetty 9 + Java> 8u74 always allocate maximum (-Xmx) memory on Linux? - java-8Sitecore redirect module - sitecoreXcode 7: "No matching training profiles found" - iosПолучение нескольких запросов API с помощью React Native - apiNuitka on Windows - windows-7-x64Can we programmatically verify that this is a variable name in standard form or not? - javaAll Articles