Mark NS
01/23/2023, 2:18 PMcontent-type
on the uploaded file is always binary/octet-stream
s3bucket: S3 = S3.load("default")
with open(local_path, "rb") as f:
s3bucket.write_path(to_path, f.read())
Does anyone have a pointer on how to set the metadata on upload? @Marvin ?Ryan Peden
01/23/2023, 4:32 PMS3
block has limits since it's built on top of fsspec
. In the `prefect-aws` collection, we have an S3Bucket block with an upload_from_file_object method I think you could use here.
It has a **kwargs
param you could use to pass metadata to the underlying boto3 library via ExtraArgs.Mark NS
01/23/2023, 5:04 PMdef upload_html(s3bucket: S3Bucket, html: str):
with BytesIO() as f:
f.write(html.encode())
f.seek(0)
s3bucket.upload_from_file_object(f, "analysis/index.html", ExtraArgs={
"CacheControl": "no-cache",
"ContentType": "text/html"
})
Ryan Peden
01/24/2023, 12:49 PM