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 <denys.f@collabora.com>
  • Loading branch information
nuclearcat committed Oct 18, 2024
1 parent 535d19f commit 4f3a2bd
Showing 1 changed file with 6 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

Check failure on line 11 in kernelci/storage/azure.py

View workflow job for this annotation

GitHub Actions / Lint

No name 'blob' in module 'azure.storage'

Check failure on line 11 in kernelci/storage/azure.py

View workflow job for this annotation

GitHub Actions / Lint

Unable to import 'azure.storage.blob'
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

0 comments on commit 4f3a2bd

Please sign in to comment.