boto-updater.py 763 B

12345678910111213141516171819202122232425262728293031
  1. import boto3
  2. import os.path
  3. # Arguments
  4. folder_to_sync = './test/data'
  5. bucket_target = 'my-bucket'
  6. # Main
  7. 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")
  8. # Get file list
  9. # Source : https://stackoverflow.com/questions/3207219/how-do-i-list-all-files-of-a-directory
  10. file_list = os.listdir(folder_to_sync)
  11. print("Local : ", folder_to_sync)
  12. print(file_list)
  13. # Upload
  14. print("Uploading ...")
  15. for file_name in file_list:
  16. print(file_name, end=' ')
  17. file_path = folder_to_sync + '/' + file_name
  18. if os.path.isfile(file_path):
  19. res = s3.upload_file(file_path, bucket_target, file_name)
  20. print('ok')
  21. else:
  22. print('(Skipped)')
  23. print("Done")