Advertisement
AMONRA75

PYTHON - S3 READ BUCKETS

Oct 2nd, 2023
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import boto3
  2.  
  3. # Sostituisci con le tue credenziali
  4. access_key = "xxxxxx"
  5. secret_key = "xxxxxx"
  6.  
  7. # Imposta l'endpoint personalizzato
  8. endpoint_url = "https://gateway.storjshare.io:443"
  9.  
  10. # Crea un client S3 con l'endpoint personalizzato
  11. s3 = boto3.client('s3', endpoint_url=endpoint_url, aws_access_key_id=access_key, aws_secret_access_key=secret_key)
  12.  
  13. # Esempio: elenco dei bucket S3
  14. try:
  15. response = s3.list_buckets()
  16.  
  17. print("I tuoi bucket S3:")
  18. for bucket in response['Buckets']:
  19. print(f" - {bucket['Name']}")
  20.  
  21. except Exception as e:
  22. print(f"Errore durante l'elenco dei bucket S3: {str(e)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement