From f4ecf5393e056a196ab054ed3d5c3e677cfbc4b3 Mon Sep 17 00:00:00 2001 From: Denys Fedoryshchenko Date: Fri, 18 Oct 2024 13:20:12 +0300 Subject: [PATCH] feat(storage/azure.py): Add content_type option for .gz files As requested by kcidb team, it will be easier to handle files if they have proper content-type set. Signed-off-by: Denys Fedoryshchenko --- kernelci/storage/azure.py | 7 ++++++- pyproject.toml | 1 + requirements.txt | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/kernelci/storage/azure.py b/kernelci/storage/azure.py index bfbe8624d1..db69821693 100644 --- a/kernelci/storage/azure.py +++ b/kernelci/storage/azure.py @@ -8,6 +8,7 @@ from urllib.parse import urljoin import os from azure.storage.fileshare import ShareServiceClient +from azure.storage.blob import ContentSettings from . import Storage @@ -68,7 +69,11 @@ def _upload(self, file_paths, dest_path): for src, dst in file_paths: file_client = root.get_file_client(file_name=dst) with open(src, 'rb') as src_file: - file_client.upload_file(src_file) + c_type = 'application/octet-stream' + if src.endswith('.gz'): + c_type = 'application/gzip' + c_settings = ContentSettings(content_type=c_type) + file_client.upload_file(src_file, content_settings=c_settings) urls[dst] = urljoin( self.config.base_url, '/'.join([self.config.share, dest_path, dst]), diff --git a/pyproject.toml b/pyproject.toml index 332f7c312c..17e6b2371a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,6 +15,7 @@ readme = "README.md" requires-python = ">=3.9" license = {text = "LGPL-2.1-or-later"} dependencies = [ + "azure-storage-blob==12.23.1", "azure-storage-file-share==12.13.0", "bson==0.5.10", "click==8.1.3", diff --git a/requirements.txt b/requirements.txt index 1bcad85187..0f1c3a78cc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +azure-storage-blob==12.23.1 azure-storage-file-share==12.13.0 bson==0.5.10 click==8.1.3