import boto3
from botocore.exceptions import NoCredentialsError
# Create an S3 client
s3 = boto3.client('s3')
# Upload a test file
try:
# Specify the file content and bucket details
file_name = '/tmp/test_file.txt'
bucket_name = 'symbolix-stg-bucket'
file_content = "This is a test file."
# Write the content to the file
with open(file_name, 'w') as file:
file.write(file_content)
# Upload the file to the S3 bucket
s3.upload_file(file_name, bucket_name, 'test_file.txt')
print("File uploaded successfully.")
except NoCredentialsError:
print("Credentials not found.")
except Exception as e:
print(f"Error uploading file: {str(e)}")
Editor is loading...