I'm trying to get the below python code to save the csv from an api to an amazon s3 bucket using bot03 and python, but I can't see where I'm going wrong. When I execute the code I don't get any error but the file never appear in the s3 bucket.
import boto3
from botocore.exceptions import ClientError
file_name = "test.csv"
bucket = "mybucket"
def main():
url = "https://api0.solar.sheffield.ac.uk/pvlive/v3/pes/10?start=2021-01-01T00:00:00&end=2021-07-06T00:00:00&data_format=csv"
x = requests.get(url,headers={'Content-Type': 'application/json', 'Accept': 'application/json', 'Accept-Encoding': 'gzip, deflate',})
s3 = bot03.client("s3")
with open("test.csv","rb") as file2:
s3.upload_fileobj(x.content, bucket, "test.cvc")
any tips/advice would be appreciated. I'm a python/aws newbie so apologies if a basic question