|
@@ -1,4 +1,5 @@
|
|
|
import boto3
|
|
|
+from botocore.exceptions import ClientError
|
|
|
import os.path
|
|
|
|
|
|
# Arguments
|
|
@@ -8,8 +9,11 @@ bucket_target = 'my-bucket'
|
|
|
# Create connection
|
|
|
s3 = boto3.client('s3', use_ssl=False, endpoint_url="http://172.17.0.2:9000", aws_access_key_id="minio", aws_secret_access_key="miniokey")
|
|
|
|
|
|
-# Reset bucket
|
|
|
-
|
|
|
+# Check bucket
|
|
|
+try:
|
|
|
+ s3.head_bucket(Bucket=bucket_target)
|
|
|
+except ClientError as e:
|
|
|
+ s3.create_bucket(Bucket=bucket_target)
|
|
|
|
|
|
# Get file list
|
|
|
# Source : https://stackoverflow.com/questions/3207219/how-do-i-list-all-files-of-a-directory
|