|
@@ -2,7 +2,7 @@ import boto3
|
|
|
import os.path
|
|
|
|
|
|
# Arguments
|
|
|
-folder_to_sync = './test/data/'
|
|
|
+folder_to_sync = './test/data'
|
|
|
bucket_target = 'my-bucket'
|
|
|
|
|
|
# Main
|
|
@@ -10,15 +10,22 @@ s3 = boto3.client('s3', use_ssl=False, endpoint_url="http://172.17.0.2:9000", aw
|
|
|
|
|
|
# Get file list
|
|
|
# Source : https://stackoverflow.com/questions/3207219/how-do-i-list-all-files-of-a-directory
|
|
|
-listOfFiles = [f for f in os.listdir(folder_to_sync) if os.path.isfile(folder_to_sync + f)]
|
|
|
+file_list = os.listdir(folder_to_sync)
|
|
|
print("Local : ", folder_to_sync)
|
|
|
-print(listOfFiles)
|
|
|
+print(file_list)
|
|
|
|
|
|
# Upload
|
|
|
print("Uploading ...")
|
|
|
-for f in listOfFiles:
|
|
|
- print(f)
|
|
|
- res = s3.upload_file(folder_to_sync + f, bucket_target, f)
|
|
|
+for file_name in file_list:
|
|
|
+ print(file_name, end=' ')
|
|
|
+
|
|
|
+ file_path = folder_to_sync + '/' + file_name
|
|
|
+
|
|
|
+ if os.path.isfile(file_path):
|
|
|
+ res = s3.upload_file(file_path, bucket_target, file_name)
|
|
|
+ print('ok')
|
|
|
+ else:
|
|
|
+ print('(Skipped)')
|
|
|
|
|
|
print("Done")
|
|
|
|