Saving plots to s3 from Python 3.6

Hi,

I’m trying to save plotly graph objects to a bucket in S3. The plots are generated weekly on the previous weeks data. I was originally trying to use boto3, but I was having difficulty with the connection on this. I found the s3fs library, and I can connect, access and write csv files to this no problem, but I’m really confused as to how to write the graph object to S3. Here is a snippet for writing a csv to s3 using s3fs

import s3fs
s3 = s3fs.S3FileSystem(anon=False, key=access_key, secret=secret_key)
with s3.open('my_bucket/file.csv','w') as f:
    df.to_csv(f)

Is there something simple like the above snippet to write what I usually save as a html file to disk that will save the html to s3? Do I need to convert it to bytes before saving it? I’m so confused about how to do this, so any help is much appreciated