[Python] Writing json to file in s3 bucket

Discussão em 'Python' iniciado por Stack, Julho 17, 2025.

  1. Stack

    Stack Membro Participativo

    This code writes json to a file in s3, what i wanted to achieve is instead of opening data.json file and writing to s3 (sample.json) file,

    how do i pass the json directly and write to a file in s3 ?

    import boto3

    s3 = boto3.resource('s3', aws_access_key_id='aws_key', aws_secret_access_key='aws_sec_key')
    s3.Object('mybucket', 'sample.json').put(Body=open('data.json', 'rb'))

    Continue reading...

Compartilhe esta Página