Skip to content

Commit f4ecf53

Browse files
committed
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 <[email protected]>
1 parent c1180d7 commit f4ecf53

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

kernelci/storage/azure.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from urllib.parse import urljoin
99
import os
1010
from azure.storage.fileshare import ShareServiceClient
11+
from azure.storage.blob import ContentSettings
1112
from . import Storage
1213

1314

@@ -68,7 +69,11 @@ def _upload(self, file_paths, dest_path):
6869
for src, dst in file_paths:
6970
file_client = root.get_file_client(file_name=dst)
7071
with open(src, 'rb') as src_file:
71-
file_client.upload_file(src_file)
72+
c_type = 'application/octet-stream'
73+
if src.endswith('.gz'):
74+
c_type = 'application/gzip'
75+
c_settings = ContentSettings(content_type=c_type)
76+
file_client.upload_file(src_file, content_settings=c_settings)
7277
urls[dst] = urljoin(
7378
self.config.base_url,
7479
'/'.join([self.config.share, dest_path, dst]),

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ readme = "README.md"
1515
requires-python = ">=3.9"
1616
license = {text = "LGPL-2.1-or-later"}
1717
dependencies = [
18+
"azure-storage-blob==12.23.1",
1819
"azure-storage-file-share==12.13.0",
1920
"bson==0.5.10",
2021
"click==8.1.3",

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
azure-storage-blob==12.23.1
12
azure-storage-file-share==12.13.0
23
bson==0.5.10
34
click==8.1.3

0 commit comments

Comments
 (0)