Skip to content

Commit

Permalink
feat(storage/azure.py): Add content_type option for .gz files
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
nuclearcat committed Oct 18, 2024
1 parent c1180d7 commit f4ecf53
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kernelci/storage/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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]),
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit f4ecf53

Please sign in to comment.