How to upload a file to S3 without creating a temporary local file

前端 未结 10 1715
無奈伤痛
無奈伤痛 2021-01-30 13:49

Is there any feasible way to upload a file which is generated dynamically to amazon s3 directly without first create a local file and then upload to the s3 server? I use python.

10条回答
  •  心在旅途
    2021-01-30 14:27

    You could use BytesIO from the Python standard library.

    from io import BytesIO
    bytesIO = BytesIO()
    bytesIO.write('whee')
    bytesIO.seek(0)
    s3_file.set_contents_from_file(bytesIO)
    

提交回复
热议问题