-
Notifications
You must be signed in to change notification settings - Fork 113
Description
When writing to azure blob storage, it's not currently possible to specify content type. For instance this:
html_contents = """
<!DOCTYPE html>
<html lang="en">
<head><title>Hello</title></head>
<body><h1>Hello world!</h1></body>
</html>
"""
with fsspec.open("abfs://container/file.html", mode="w", **storage_options) as file:
file.write(html_contents)will be uploaded to azure blob storage as the default "application/octet-steam" rather than "text/html". Azure blob storage can be used to host static sites, for instance, but requires it knows the content types (text/html, text/javascript, etc) of files.
It would be really handy if this was possible:
with fsspec.open("abfs://container/file.html", mode="w", content_type="text/html", **storage_options) as file:
file.write(html_contents)azure sdk blob client offerns a content_settings keyword argument that works like this:
blob_client.upload_blob(
contents,
content_settings=ContentSettings(content_type="text/html"),
)
I think passing this in from an adlfs perspective would just be something like this for spec.py (lines 1574):
await bc.upload_blob(
f1,
overwrite=overwrite,
metadata={"is_directory": "false"},
raw_response_hook=make_callback(
"upload_stream_current", callback
),
max_concurrency=max_concurrency or self.max_concurrency,
content_settings=ContentSettings(content_type=content_type),
**self._timeout_kwargs,
)It would be simple enough to default to not passing in an argument unless specified, so shouldn't (in theory) cause any changes to existing code.
But I'm not sure I understand enough about fsspec and adlfs's interaction. Does fsspec just pass any additional keyword arguments down the chain so that the earlier example would work as expected?